-
Notifications
You must be signed in to change notification settings - Fork 45
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
i18n: adds translation support #307
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have discussed with @zzacharo and it looks a nice implementation, it is maybe missing a little bit more "plumbing".
To extract all the translations, it looks like that we can use 18next-scanner (to be tested!!!). It could be added as a command in the package.json
.
Then we will have to document how to upload the extracted keys to Transifex, and we might need some config file here for the Transifex integration.
At the end, when we download the .po
catalog from Transifex with the translations, we found that we could use i18next-gettext-converter, again to be tested and integrated in the package.json
.
What do you think?
I like it, sounds like a plan. I will start digging into this. Thanks |
bcc7bd0
to
6f6fa45
Compare
f48b5bc
to
a526762
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks very good @mb-wali !!! Just some small comments but the flow seem neat!
@@ -17,6 +17,9 @@ | |||
"postlink-dist": "cd dist && rm -rf node_modules", | |||
"unlink-dist": "cd dist && npm unlink && rm package*", | |||
"watch": "NODE_ENV=development rollup --watch -c", | |||
"i18n-scan": "i18next-scanner --config i18next-scanner.config.js src/**/*.{js,jsx}", | |||
"i18n-conv-json": "i18next-conv -l en -s ./src/lib/translations/en/translations.json -t ./src/lib/translations/translations.pot", | |||
"i18n-conv-po": "i18next-conv -l $npm_config_lang -s ./src/lib/translations/$npm_config_lang/messages.po -t ./src/lib/translations/$npm_config_lang/translations.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we will need to have i18n-conv-po-all
function to compile all the .po
files for all available languages...Maybe the configured languages could be set here as a config variable https://docs.npmjs.com/cli/v7/configuring-npm/package-json#config
9fca721
to
0816daf
Compare
"i18n-scan": "i18next-scanner --config i18next-scanner.config.js src/**/*.{js,jsx}", | ||
"i18n-conv-json": "i18next-conv -l en -s ./src/lib/translations/en/translations.json -t ./src/lib/translations/translations.pot", | ||
"i18n-conv-po": "i18next-conv -l $npm_config_lang -s ./src/lib/translations/$npm_config_lang/messages.po -t ./src/lib/translations/$npm_config_lang/translations.json", | ||
"i18n-conv-po-all": "node ./getTextConverter.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mb-wali what about merging the i18n-conv-po
and this command by simply adding an extra argument e.g --all
to comply also with what tx
command is using for pulling all languages? I can approve this PR if you think this is a lot of work to be done now and we can open an issue for that :)
related issue inveniosoftware/react-invenio-forms/issues/6
Uploads.mp4
Dependencies
i18next
i18next-browser-languagedetector
(detect user language)i18next-scanner
(extract translation keys/values)i18next-conv
(converts files from gettext (.mo/.po) to i18next's json format and vice versa)Mark for translation
import created instance in your package.
import i18next from '../i18next';
Mark for translation
Extract translations
To scan your code, extract translation keys/values, and merge them into i18n resource files.
Create/update .pot file, this file is pushed to transifex
converts source language file from
JSON
to.pot
Convert/update .po files to json.
once translation is pulled from transifex, the format is
.po
, in order to convert these files to JSON format run following command.Convert/update all the .po files for all available languages