Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions docs/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@ into the app is fully automated as part of the release process.

## Supported Languages

We currently support the magnificent 16 languages defined in `common/lib/locale.ts`,
as well as Polish, Vietnamese, Ukrainian and Hungarian.
If you want to add support for another language you will need to add it to the
`supportedLocales` array and add a corresponding `studio-<locale>.jed.json` file
in `tools/common/translations/`.
The set of supported languages is defined by `supportedLocaleNames` in
`tools/common/lib/locale.ts`. To add a new language:

1. Add a `studio-<locale>.jed.json` file in `tools/common/translations/`.
2. Import it and register it in `localeDataDictionary` in
`tools/common/translations/index.ts`.
3. Add a `supportedLocaleNames` entry (its display name) in
`tools/common/lib/locale.ts`.

The `supportedLocales` array is derived automatically from `supportedLocaleNames`,
so it does not need to be edited by hand.

The `<locale>` slug must match the language's slug in the
[Studio GlotPress project](https://translate.wordpress.com/projects/studio/) — the
automated export (see below) downloads from `…/<locale>/default/export-translations/`
and fails if that locale does not exist there.

## Translation Process

Expand All @@ -30,8 +41,10 @@ from GlotPress in Jed 1.x JSON format (which `@wordpress/i18n` understands) and
them directly to the release branch before bumping the version. It's ok if some translations
are missing — they will be left as English in the app.

The lane discovers locales from the existing `studio-*.jed.json` files in
`tools/common/translations/` and downloads each one from GlotPress.
The lane discovers locales by globbing the existing `studio-*.jed.json` files in
`tools/common/translations/` (e.g. `studio-ckb.jed.json` → `ckb`) and downloads each
one from GlotPress. There is no separate allowlist — adding a translation file is what
opts a locale into the automated download.

No manual steps are needed for translation export. The standalone `fetch_glotpress_translations`
lane can be used to manually download translations if needed.
1 change: 1 addition & 0 deletions tools/common/lib/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type SupportedLocale = keyof typeof localeDataDictionary;

export const supportedLocaleNames: Record< SupportedLocale, string > = {
ar: 'العربية',
ckb: 'کوردیی ناوەندی',
de: 'Deutsch',
en: 'English',
es: 'Español',
Expand Down
3 changes: 3 additions & 0 deletions tools/common/translations/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { locale_data as ar } from '@studio/common/translations/studio-ar.jed.json';
import { locale_data as ckb } from '@studio/common/translations/studio-ckb.jed.json';
import { locale_data as de } from '@studio/common/translations/studio-de.jed.json';
import { locale_data as es } from '@studio/common/translations/studio-es.jed.json';
import { locale_data as fr } from '@studio/common/translations/studio-fr.jed.json';
Expand All @@ -24,6 +25,7 @@ type LocaleData = {
};
type SupportedLocale =
| 'ar'
| 'ckb'
| 'de'
| 'en'
| 'es'
Expand All @@ -47,6 +49,7 @@ type SupportedLocale =

export const localeDataDictionary: Record< SupportedLocale, LocaleData | null > = {
ar,
ckb,
de,
en: null,
es,
Expand Down
1 change: 1 addition & 0 deletions tools/common/translations/studio-ckb.jed.json

Large diffs are not rendered by default.

Loading