-
Notifications
You must be signed in to change notification settings - Fork 503
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!: Implement localization support into Yari (and localize BCD tables) #6282
Conversation
poking @mdn/localization-team-leads regarding the topic here :) |
17fe178
to
065fab3
Compare
This pull request has merge conflicts that must be resolved before we can merge this. |
(I've got no clue why the Developing with Yari test isn't working...I'm not having any problems with it on my end.) |
I now see that the same test script is failing in other PRs as well: https://github.com/mdn/yari/runs/6502514714?check_suite_focus=true So I'm not worried about that test run any longer. |
This pull request has merge conflicts that must be resolved before we can merge this. |
Hey @queengooborg! Thank you so much for this pull request. This is amazing work. We are discussing this internally and will reach out to you soon. |
Just for reference mdn/translated-content#6943 |
This pull request has merge conflicts that must be resolved before it can be merged. |
Converted to draft pending our decision on how to move forward. |
This pull request has merge conflicts that must be resolved before it can be merged. |
This pull request has merge conflicts that must be resolved before it can be merged. |
This PR introduces localization of the Yari platform itself, so that translators can localize the platform's common elements as well as the content. It utilizes
react-i18next
to do as such, a top rated localization package for all of NodeJS. (This is a pretty big change as it introduces a brand new API for handling strings.) As a proof-of-concept, I have made the compatibility tables localizable.Design
For the strings, the
i18next
format is used, which handles variable interpolation, formatting, pluralization, arrays, and more. Whilei18next
uses the handlebars format (that is,{{ }}
), TypeScript wasn't happy with this, so I switched the delimiters to two square brackets ([[ ]]
).The setup also takes advantage of the multi-file structure provided by
i18next
, which means that translations may be separated into multiple folders for each language, and multiple files for each group of strings (called "contexts"). In other words, strings specific to the BCD tables may be stored inbcd.json
, while navigation bar strings may be stored innavigation.json
. With the multi-file structure in mind, I've set it up so that localization may live inmdn-translated-content
rather than here in Yari. All translations will live in one repository, with files for Yari's platform localization stored infiles/<locale>/_yari/<namespace>.json
.Translation Steps
To translate the strings for the Yari platform, translators may perform the following:
mdn/yari/client/i18n/
in this repository and paste it inmdn/translated-content/files/<locale>/_yari/
i18n
folder