-
Notifications
You must be signed in to change notification settings - Fork 71
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
Feat/i18n #465
base: master
Are you sure you want to change the base?
Feat/i18n #465
Conversation
Thanks, that's impressive work. I'm wondering if this is really the correct way of doing translation though. The way I'm familiar with is to have .po files storing the translation, which avoids having to store text through multiple indirections like you're doing here. Have you investigated translation libraries based on .po files? |
I've only ever done translation via json files on javascript frontend projects (on react mainly) before as this is what most of the big i18n libs work with.
|
I don't know either what's the "correct" way of doing it, I might need to look into that more. However the convenient thing about gettext-based methods is that you can write all your code normally in English without caring about the translation at all, and the translation is just an overlay on your English text, entirely in separate .po files. This feels better than having codenames for all the strings, from a programming point of view. |
I see your point, gettext seems to make code and transaltion more readable in general. I tried keeping plain english in code at first but I encountered issues with words translating to something else depending and context and not switching to translation key would have produced a lot of duplication. I've seen that gettext seems to handle a context along the translation so that would take care of that problem. From the little research I've done it seems that the .po file has to be converted to a json file to be readable by the browser, this can be done either at build time (with webpack plugin, but we use vite) or beforehand with CLI tools (Which could be automated to be run on commit or during deployment ?). (Or at runtime but that seems to be a bad idea because of performances) |
Hey,
I've been working on the internationalization feature implementation because the last PR is 6 years old and I think the feature would benefits to a lot of users, it includes:
I only added french translation because it is my main language but it should be easy to add new ones.
To add new locales:
src/locales
folder (template.json
is the empty file that can be used as base)src/util/i18n.js
I tried to reduce the size of the translation files as much as I could but it still ended up pretty big 😩
Please let me know if you have any question or feedback on the feature or the translation 😃