yari icon indicating copy to clipboard operation
yari copied to clipboard

Implement localization support into Yari (and localize BCD tables)

Open queengooborg opened this issue 3 years ago • 15 comments

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

queengooborg avatar May 15 '22 09:05 queengooborg

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

SphinxKnight avatar May 15 '22 09:05 SphinxKnight

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

github-actions[bot] avatar May 18 '22 11:05 github-actions[bot]

(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 avatar May 18 '22 12:05 queengooborg

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.

queengooborg avatar May 19 '22 07:05 queengooborg

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

github-actions[bot] avatar May 20 '22 13:05 github-actions[bot]

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.

schalkneethling avatar May 20 '22 13:05 schalkneethling

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

github-actions[bot] avatar May 20 '22 22:05 github-actions[bot]

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

github-actions[bot] avatar May 23 '22 11:05 github-actions[bot]

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

github-actions[bot] avatar May 24 '22 11:05 github-actions[bot]

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

github-actions[bot] avatar May 25 '22 11:05 github-actions[bot]

@queengooborg Thank you. We had some discussions around this topic, healthy ones. We'll review and work on this next week. But this might take a while to land as this is not the highest priority. Glancing over this PR it looks great, the big missing piece to this is SSR. That's currently hard to build and might take some time.

fiji-flo avatar May 27 '22 11:05 fiji-flo

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

github-actions[bot] avatar May 27 '22 14:05 github-actions[bot]

@fiji-flo Thank you! I started some work on SSR but backed out of it due to build failures for now -- I'd be happy to try again should we want to go forward with this!

queengooborg avatar May 27 '22 17:05 queengooborg

Just for reference mdn/translated-content#6943

Jalkhov avatar Aug 04 '22 20:08 Jalkhov

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

github-actions[bot] avatar Aug 07 '22 18:08 github-actions[bot]

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

caugner avatar Dec 01 '22 00:12 caugner