Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.96 KB

translation.md

File metadata and controls

37 lines (29 loc) · 1.96 KB

Translating TypeLearn

For translators, see the Translating section of the README. This page is for developers changing interface text.

The interface text lives in src/frontend/src/locales/, one JSON file per language. en.json is the source: every other language is translated from it, and any string a language has not translated yet shows in English.

Keys are nested objects grouped by component (settings → button → label) and looked up by their dotted path, t('settings.button.label'). Don't write a flat "settings.button.label" key: a file would end up mixing both shapes. keys.test.ts fails on dotted keys.

To change a translation, edit that language's file in a normal pull request. To add a string, add it to en.json and to every other language file in the same pull request.

A string that depends on a number gets one key per plural form, named the i18next v4 way: symbolCount_one and symbolCount_other inside sentence in en.json. Render it with tPlural(key, count) from src/frontend/src/i18n.ts, not t. The helper picks the form the active language needs, so each language has its own plural forms, such as _few and _many for Russian.

Adding a language

A new JSON file alone does nothing. The app only loads the languages it lists. To add one, open a pull request that, under src/frontend/src/:

  1. adds locales/<code>.json as an empty {}, unless a translator already started the language and its file exists,
  2. in i18n.ts, imports that file, adds it to the catalogs passed to createI18n, and adds the code to SUPPORTED_LANGUAGES,
  3. adds the language's own name for itself (e.g. "Deutsch") to LANGUAGES in components/SettingsMenu.vue, in the same position as in SUPPORTED_LANGUAGES, and to the expected list in components/__tests__/SettingsMenu.test.ts,
  4. imports the file in locales/__tests__/keys.test.ts and adds it to CATALOGS, so its keys and placeholders are checked too.