scripts/check-i18n.sh fails a commit that adds literal JSX text to a file outside t()), English is the source language. Spanish (es) ships today, and German, French, Brazilian Portuguese, Japanese and Simplified Chinese are registered and fall back to English until their folders land. Many older components still hardcode English: migrate a component when you touch it, and run scripts/i18n-inventory.sh to list the files with the most remaining literal strings.
The stack is react-i18next with i18next, in the plain Vite and React app. It gives you plain t('key') calls with no extraction step, namespace-based lazy loading, and typed keys.
Where strings live
Translations are inweb/src/locales/<language>/<namespace>.json. A namespace maps to a feature area, not to one component: deploys.json holds keys for several deploy-settings cards. There are 157 namespaces, one JSON file each under web/src/locales/en/, and NAMESPACES in web/src/i18n/index.ts is the full list.
Nest keys by component inside the file, and name a key for what the string is for, not its English text:
Add a string to a component
1
Add the key to the JSON file
Find or create the namespace file under
web/src/locales/en/ and add the key first. The JSON file is the type schema, so a call site cannot use a key that is not there.2
Call t() in the component
{{placeholder}} in the value and pass the data as the second argument: t('autoRollbackSloBurn.toast.modeSet', { mode: label }). For strings from more than one namespace, pass an array to useTranslation and prefix the non-default key, for example t('common:actions.copy').3
Cover every user-facing string
That includes
aria-label values, toast titles and descriptions, tooltip text and alt text. Test ids, internal log messages and class names do not belong in a namespace file.4
Check types
From
web/, run npx tsc -b and npx eslint src. A missing or mistyped key fails tsc.Adding a new namespace
Create the JSON file, then register it in two places: add the name toNAMESPACES in web/src/i18n/index.ts and add its type to web/src/i18n/resources.ts.
How loading works
Each namespace is its own chunk.web/src/i18n/lazyBackend.ts imports ../locales/${language}/${namespace}.json with a fixed directory and extension, which lets Vite split every JSON file out of the main bundle. A namespace downloads the first time a component calls useTranslation for it. Only common, the default namespace, loads at boot.
Because useSuspense is on, a component suspends while its namespace loads. web/src/main.tsx wraps the app in one <Suspense fallback={<PageSpinner />}>, so this looks like any other route loading state. If you render a component outside that tree, make sure an ancestor has a Suspense boundary.
Type-safe keys
web/src/i18n/resources.ts augments i18next’s CustomTypeOptions with the type of each en JSON file:
t('autoRollback.titl') is a tsc error at the call site instead of a silent fallback to the raw key at runtime. This needs "resolveJsonModule": true in tsconfig.app.json, which is set.
Testing
Test a translated component with a dedicatedi18next.createInstance() seeded with the real namespace JSON through I18nextProvider, not the app’s lazy-loading singleton. Tests then get deterministic, already-loaded translations with no chunk-loading race. web/src/components/AutoRollbackCard.test.tsx shows the pattern.
Languages and fallback
Supported codes live inSUPPORTED_LANGUAGES in web/src/i18n/supported.ts: en, es, de, fr, pt-BR, ja and zh-CN. Users pick one under Settings, Account, Preferences (Language), and the browser language is used when they have not. The picker names each language in itself (Intl.DisplayNames), English first, then alphabetical by native name.
Detected tags are normalised in web/src/i18n/detect.ts before matching: pt and pt-PT become pt-BR, zh, zh-Hans and zh-SG become zh-CN, and regional tags such as es-MX or en-US resolve to es and en. Traditional Chinese (zh-TW, zh-Hant) is not covered and falls back to English.
A language does not have to translate everything. A missing namespace file loads as empty and a missing key falls back to English, so a partial locale is safe to ship, and a language whose folder does not exist yet simply shows English.
Add a language
- Add its code to
SUPPORTED_LANGUAGESinweb/src/i18n/supported.ts. - Create
web/src/locales/<code>/and add one JSON file per namespace you translate, with the same keys,{{placeholders}}and tags as English. Followweb/src/i18n/glossary.json(see below). - Add
web/src/i18n/loaders/<code>.ts(copy an existing one and change the folder) and one line for it inweb/src/i18n/lazyBackend.ts. Each language has its own loader so only English and the active language’s file map load at first paint;loaders.test.tsfails if a folder, a loader andSUPPORTED_LANGUAGESdisagree. - Run
node web/src/i18n/checkLocale.mjs <code>(add namespace names to check only those), orscripts/check-locales.sh --all. Fix every line it prints. - Run
cd web && npx vitest run src/i18n. The suites discover every folder underweb/src/localesexcepten, so no test edit is needed.
web/src/i18n/missingBaseline/<code>.json as { "missing": ["ns:key"], "knownIssues": ["<checker line>"] }. A language with no baseline file must have zero gaps and zero issues, and a baseline entry that has since been fixed fails the test until you delete it. Spanish has a baseline for the namespaces it does not yet translate in full.
scripts/check-locales.sh runs the checker for each language whose files changed against the base branch. Preflight runs it on push when web/src/locales or web/src/i18n changed, so it stays off the commit path.
What the checks enforce
web/src/i18n/localeCheck.mjs is the single source for the CLI and the vitest suites:
- valid JSON, and every file has an English counterpart
- no key that is not in English
- the same
{{placeholders}}and numbered or named tags as English - no em or en dash
- protected glossary terms kept (
doNotTranslateinglossary.json: product and protocol names such as Docker, Git, TLS, Compose) - no English key missing from a shipped namespace, beyond the baseline
- every plural form the language needs, see below
Glossary
web/src/i18n/glossary.json holds three things: doNotTranslate (terms that must appear unchanged), keepEnglishOrLoan (established devops words such as deploy, rollback and token, kept in English or the local loan form and used consistently) and style (register per language, for example formal address in German and French).
Plurals per language
Plural keys use i18next suffixes:count with _one, _other and so on. English defines _one and _other. The checker asks Intl.PluralRules which forms the language uses for whole numbers and requires every one of them for each English plural key. Japanese and Chinese need only _other, German, French, Spanish and Brazilian Portuguese need _one and _other, and a language such as Russian also needs _few and _many. Forms that only apply to compact decimals (many in Spanish and French) are not required.
Right to left
web/src/i18n/direction.ts keeps <html lang> and <html dir> in step with the active language, on initialized and on every languageChanged, using i18n.dir(). isRtlLanguage and directionFor are exported for code that needs the direction. None of the registered languages is RTL yet: before adding one (Arabic, Hebrew), use logical Tailwind utilities (ms-*, ps-*, text-start) in the components that matter and mirror directional icons.
Formatting
Dates, numbers and relative times use the active language throughIntl (getActiveLocale() in web/src/lib/activeLocale.ts), not through translated strings. Do not build a number or date by concatenating translated pieces; pass the value as an interpolation and let Intl format it.
Accessibility checks
web/src/test/pagesA11y.test.tsx mounts the main pages and the command palette and runs the static checker in web/src/test/a11y.ts (names, labels, ARIA references, tabindex, nested controls, headings). web/src/test/contrast.test.ts computes WCAG AA contrast for the shared colour tokens in index.css, so fix contrast by changing a token, not a component.