Requirements

General problem: trying to find a file format that Transifex supports that can give us the first two items.  We could turn .json into .po but (probably on the inverse transformation) that breaks plurals.  The .po plural format is so hairy we actually haven't found any packages online that convert it to .json, so I guess nobody else wanted to do it either.  (smile)

See whiteboard photos here.  See how studio-frontend did it here (caveat: we won't be taking their entire process).

Process

Legend: (tick) Working in user account app.  (question) Open question.

(tick) in .jsx files: react-intl

(tick) extraction: many .jsx → many .json

(tick) concatenation: many .json → one .json (or other format)

validation (not needed for first draft)

(tick) translation: jobs run weekly on Jenkins

(tick) incorporation: translated .json → react-intl

react-intl and gender agreement

PL translation:

Male:

Female:

Other:

Incorporating i18n dependencies

Definitions

Optimal choice: Avoid

When possible, components should accept an already-localized string as props, deferring the localization to elements higher up in the element hierarchy.

If you must: Aggregate

Components that need to provide their own i18n must also manage their own translations.  This means they will need to have their own translations job on Jenkins.

Because translations can take a long time (e.g., weeks or months) to come in, we want consumers to be able to update the translations for their dependencies, without necessarily pulling in code changes for those dependencies that have happened in the meantime.  This requirement implies that translations should be packaged and versioned side by side with, but separately from, the code.

Components must aggregate the translations from their dependencies in their own dependency package.  Example:  Say the Footer component is i18n'ized, and it uses another component FooterSubcomponent that is also i18n'ized.  Then the translations package that Footer generates should include the translations for FooterSubcomponent as well.

Implications

  1. If you introduce new messages in a code commit, you should remember to bump your messages peer dependency in package.json so your consumers are reminded to bump their translations version.
  2. A top-level MFE might wish to support languages that its dependencies don't (yet).  The devs will need to add the necessary languages to those components.
  3. A non-top-level component that doesn't do its own i18n, but that uses a dependency that needs i18n, will still need to package that dependency's translations.
  4. A change in the translations for a component won't show up until all the components above it are rebuilt.
  5. If you bump your translation version but not your code version for a dependency, you might get extra strings that your version of the code isn't using.  We're okay with this for now.
  6. Transifex will never see a bundled list of strings to translate, only the strings directly from an individual repo.
  7. Namespace your message ids.  ( (question) Enforce?)

Rejected Alternatives

Future to-do