-
Notifications
You must be signed in to change notification settings - Fork 418
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 scripts improvements #559
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.
LGTM as far as I understand it, likely could do with a second set of 👀 for testing
// locale that need exactly the ".zero", ".one", ".other" keys, even if we are extracting English strings | ||
locales: ["lv"], | ||
// locale that need exactly the 6 forms, even if we are extracting English strings | ||
locales: ["ar"], |
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.
I wonder why make ar the default instead of en
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 is explained in the comment above the line:
- our translation system requires us to define 6 keys for plurals (
[key].zero
,[key].one
,[key].two
,[key].few
,[key].many
,[key].other
) - the tool we use (
i18next-parsers
) extracts these plural keys based on the source locale. Since English has onlyone
andother
forms, if we seten
as the source locale it would extract only[key].one
and[key].other
ar
has all six forms, so setting it as the source locale has the effect of letting the tool extract all the needed strings
My bad, sorry. I have PR opened with fetching translations for this |
🎉 This PR is included in version 4.2.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
This PR adds some improvements to the scripts used for downloading and extracting translation strings for the JS modules. The scripts were added when we had only one module, so they needed some tweaks to make it easier to work with multiple modules.
bin/update-modules-translations.mjs
MODULES
mapping. Now the script searches for all the files matching thesrc/modules/**/translations/en-us.yml
glob and downloads the translation files.bin/extract-strings.mjs
src/modules/**/translations/en-us.yml
glob and extracts strings for each module using thesrc/modules/[MODULE_NAME]/**/*.{ts,tsx}
glob.--module
parameter.--mark-obsolete
flag. Sometimes we remove some strings on a branch but we want to deprecate them later when we merge the branch onmaster
Note
I ran the extract-strings script on
master
andservice-catalog
branches and found some inconsistencies in the strings used in the source code and the translation files, for example:copenhagen_theme/src/modules/new-request-form/fields/attachments/FileListItem.tsx
Line 104 in 6840432
arria-label
) while the key in the yml file is correctcopenhagen_theme/src/modules/service-catalog/useNotifyError.tsx
Line 19 in d29494d
new-request-form
module in theservice-catalog
module.We will need to open other PRs to fix these issue.
Checklist