Skip to content
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

Closed
wants to merge 28 commits into from

Conversation

queengooborg
Copy link
Collaborator

@queengooborg queengooborg commented May 15, 2022

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. While i18next 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 in bcd.json, while navigation bar strings may be stored in navigation.json. With the multi-file structure in mind, I've set it up so that localization may live in mdn-translated-content rather than here in Yari. All translations will live in one repository, with files for Yari's platform localization stored in files/<locale>/_yari/<namespace>.json.

Translation Steps

To translate the strings for the Yari platform, translators may perform the following:

  • Copy a file from mdn/yari/client/i18n/ in this repository and paste it in mdn/translated-content/files/<locale>/_yari/
  • Translate each string within the JSON file
    • Any strings missing from the copied file will default to English
  • Repeat for each file in the i18n folder

@SphinxKnight
Copy link
Member

poking @mdn/localization-team-leads regarding the topic here :)

@schalkneethling schalkneethling added enhancement Improves an existing feature. localization i18n & l10n labels May 16, 2022
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before we can merge this.

@github-actions github-actions bot added the merge conflicts 🚧 Please rebase onto or merge the latest main. label May 18, 2022
@github-actions github-actions bot removed the merge conflicts 🚧 Please rebase onto or merge the latest main. label May 18, 2022
@queengooborg
Copy link
Collaborator Author

(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.)

@queengooborg
Copy link
Collaborator Author

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
https://github.com/mdn/yari/runs/6464968135?check_suite_focus=true

So I'm not worried about that test run any longer.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before we can merge this.

@github-actions github-actions bot added the merge conflicts 🚧 Please rebase onto or merge the latest main. label May 20, 2022
@schalkneethling
Copy link
Contributor

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.

@SphinxKnight SphinxKnight mentioned this pull request May 20, 2022
2 tasks
@github-actions github-actions bot removed the merge conflicts 🚧 Please rebase onto or merge the latest main. label May 20, 2022
@github-actions github-actions bot added dependencies Pull requests that update a dependency file and removed merge conflicts 🚧 Please rebase onto or merge the latest main. labels Aug 4, 2022
@Jalkhov
Copy link
Member

Jalkhov commented Aug 4, 2022

Just for reference mdn/translated-content#6943

@github-actions github-actions bot added the merge conflicts 🚧 Please rebase onto or merge the latest main. label Aug 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2022

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added the 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. label Nov 16, 2022
@caugner caugner marked this pull request as draft December 1, 2022 00:20
@caugner
Copy link
Contributor

caugner commented Dec 1, 2022

Converted to draft pending our decision on how to move forward.

@github-actions github-actions bot removed the 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. label Dec 1, 2022
@github-actions github-actions bot added the idle label Dec 31, 2022
@github-actions github-actions bot added plus work around features related to MDN Plus merge conflicts 🚧 Please rebase onto or merge the latest main. and removed merge conflicts 🚧 Please rebase onto or merge the latest main. idle labels Feb 9, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

This pull request has merge conflicts that must be resolved before it can be merged.

@queengooborg queengooborg changed the title Implement localization support into Yari (and localize BCD tables) feat!: Implement localization support into Yari (and localize BCD tables) Feb 24, 2023
@github-actions github-actions bot removed the merge conflicts 🚧 Please rebase onto or merge the latest main. label Feb 25, 2023
@github-actions github-actions bot added the merge conflicts 🚧 Please rebase onto or merge the latest main. label Mar 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added the idle label Apr 5, 2023
@github-actions github-actions bot removed the idle label Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement Improves an existing feature. localization i18n & l10n merge conflicts 🚧 Please rebase onto or merge the latest main. needs decision from engineering plus work around features related to MDN Plus
Projects
Development

Successfully merging this pull request may close these issues.

6 participants