New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flatten translations #916
Comments
We can use dots instead of underlines which is easier to copy & paste. {
"landing.header.buttons.overview": "Overview"
} $t('landing.header.buttons.overview') |
@m0ksem pretty sure it'll break vue i18n (it will try to resolve nested). how exactly are dots easier to copy? |
After translating the documentation into Russian, I can highlight the following cons of flatten structure:
In general, refactoring is necessary for locales, but you might consider post-generation of a flat locale file, for example, collapse the path into a string (key). For example: // Convenient navigation, clear structure
{
"shared": {
"overview": "Overview",
"description": "Description",
"notification": {
"success": "Success notification",
"error": "Error notification"
}
},
"someModule": {
"name": "Some module name"
}
}
// Flatten structure, difficult to search option
// You will need to keep the key pattern in mind
{
"shared_overview": "Overview",
"shared_description": "Description",
"shared_notification_success": "Success notification",
"shared_notification_error": "Error notification",
"someModule_name": "Some module name"
} A non-object approach is not intuitive for developers, therefore, describing translations of documentation will be annoying. |
Hmm. Fair point.
And call it a day. |
@m0ksem dot-separator difficult to understanding, because it means object path. |
@asvae I can do this, anyway the next task is about locales. |
@mxmvshnvsk sure, thanks. Won't be able to update this issue today, but feel free to ping me in discord. :) |
How about making a simpler file structure?
In this case, we can add the locale files to the page. Then merge it into one global locale. This will be more complex, but we will have fewer larger locale files. I'm not sure we really need this, but it's an idea.
|
@m0ksem I would leave one file for now, just for ease-of-support. We might make more translation files when docs grow up as we'd need to lazy load translations most likely. |
Currently in translations we have nested collection.
That's not ideal because:
Instead we can try flat collection.
Here's an example of flat collection:
Implementation
introduce a script that
some.translation
, neversome.${translation}
).You can use yargs to introduce arguments, but generally we want this script to "somehow work", as it's probably going to be used once, then forgotten. So speedrunning this task would make the most sense.
Bonus points
The text was updated successfully, but these errors were encountered: