Managing URLs
Rosey provides some options for managing URLs. Rosey can ignore some URLs altogether, and Rosey URL locale files can contain translated URLs for your website in a given language.
If you just want to move one language to the root of the site, e.g. serve /en/index.html
at index.html
instead, see the
Default language at root option for Rosey’s build step.
#Telling Rosey to ignore URLs
If you have a URL on a page that you do not want Rosey to rewrite, you can add the data-rosey-ignore
attribute to it.
<a href="/posts/"> Posts </a>
<a data-rosey-ignore href="/contact/"> Contact </a>
When built to a page in an fr
locale, the first tag would link to /fr/posts/
, while the tag with data-rosey-ignore
would remain pointing at /contact/
.
#Creating translated URL locale files
Creating URL locale files is not a step performed by Rosey. This part of the translation workflow is left open ended, usually integrating into an existing translation workflow for a company, or being programmatically created by transforming the input URLs.
Rosey will look for URL locale files alongside the standard locale files. For a file at rosey/locales/es.json
, Rosey will look for URLs at rosey/locales/es.urls.json
.
Locale files should be created based on the base URL file output from the Rosey generate command. For the example base URL file:
{
"version": 2,
"keys": {
"index.html": {
"original": "index.html"
},
"home/index.html": {
"original": "home/index.html"
},
"posts/hello-world.html": {
"original": "posts/hello-world.html"
}
}
}
The rosey/locales/ja-jp.urls.json
locale file should match the structure:
{
"index.html": {
"original": "index.html",
"value": "index.html"
},
"home/index.html": {
"original": "home/index.html",
"value": "家/index.html"
},
"posts/hello-world.html": {
"original": "posts/hello-world.html",
"value": "投稿/こんにちは世界.html"
}
}
Each of these keys is an object with original
and value
strings. The value
string should contain the translated destination file, and will be used by Rosey when building your final multilingual site.
The output should always include the .html
extension. Rosey will remove any trailing index.html
filename where able.
All internal links to these files will be updated within the target locale.