返回 CodeWhale
LOCALIZATION.md
根目录 / docs / LOCALIZATION.md
1 # Localization Matrix
2
3 > 阅读简体中文版:[zh_hans/LOCALIZATION.md](zh_hans/LOCALIZATION.md)。
4
5 Canonical tracking document for every locale Codewhale ships, is actively
6 building, is planning, or has explicitly deferred.
7
8 > **Scope note (2026-07-12):** this matrix covers three surfaces — the TUI
9 > locale packs (`crates/localization/locales/`), the translated READMEs (`docs/i18n/`),
10 > and the website (`web/`). The three ship on different cadences, so a
11 > locale can be **shipped** on one surface and **planned** on another; the
12 > per-surface tables below are the per-surface truth. The website registry
13 > is `web/lib/i18n/config.ts` (`ALL_LOCALES`): the locale switcher and route
14 > generation both derive from it.
15 >
16 > Docs translations are **not** a locale surface: they live under
17 > `docs/zh_hans/` and `docs/id/`, and their status is tracked in
18 > `docs/zh_hans/README.md` and issue #5482, not in this matrix.
19
20 Customer-visible copy also follows the [Codewhale voice and terminal
21 charter](VOICE.md); commands, key names, and glyphs remain code-owned around
22 localized prose.
23
24 Last updated: 2026-08-18 (docs/zh_hans/ restructure; docs translation
25 status tracked outside this matrix, per #5482).
26 Source-of-truth README: `README.md` (English, post-#3087).
27
28 ## Status legend
29
30 | Status | Meaning |
31 |--------|---------|
32 | **shipped** | Live on codewhale.net and/or published as a standalone README, or a TUI pack at exact `en.json` parity |
33 | **partial** | Shipped but intentionally incomplete; missing scope falls back to English and the partial status is visible |
34 | **planned** | Explicitly prioritized for the next wave |
35 | **deferred** | Acknowledged as wanted but not yet scheduled; needs layout QA, bridge support, or community champion |
36
37 ---
38
39 ## TUI locale packs
40
41 The TUI packs under `crates/localization/locales/` are the largest translation
42 surface in the repo. `en.json` is the reference; a pack is **complete**
43 only at exact raw key parity with it, enforced by
44 `scripts/check-tui-locale-parity.py` (CI) and the parity tests in
45 `crates/localization/src/lib.rs`. See `crates/localization/locales/AGENTS.md` for the
46 authoring contract.
47
48 | Locale | File | Keys vs `en.json` | Status | Notes |
49 |--------|------|--------------------------|--------|-------|
50 | English | `en.json` | all | **shipped** | Reference pack. |
51 | Japanese | `ja.json` | all | **shipped** | Complete. |
52 | Simplified Chinese | `zh-Hans.json` | all | **shipped** | Complete. |
53 | Traditional Chinese | `zh-Hant.json` | all | **shipped** | Complete (#5143). Awaiting native-speaker review. |
54 | Brazilian Portuguese | `pt-BR.json` | all | **shipped** | Complete. |
55 | Latin American Spanish | `es-419.json` | all | **shipped** | Complete. Note the website tracks `es` — the shipped TUI pack is Latin American Spanish, not `es-ES`. |
56 | Vietnamese | `vi.json` | all | **shipped** | Complete. |
57 | Korean | `ko.json` | all | **shipped** | Complete. |
58 | Catalan | `ca.json` | all | **shipped** | Complete (#4749/#4788). Awaiting native-speaker review. |
59 | German | `de.json` | all | **shipped** | Complete (#4788). Awaiting native-speaker review. |
60 | French | `fr.json` | all | **shipped** | Complete (#4788). Awaiting native-speaker review. |
61 | Indonesian | `id.json` | all | **shipped** | Complete (#4789). Awaiting native-speaker review. |
62 | Hindi | `hi.json` | all | **shipped** | Complete (#4790). The Devanagari shaping spike (moved out of this repository in `7242381022`) gave code-level guarantees only; terminal visual QA and native review still open. |
63 | Russian | `ru.json` | all | **shipped** | Complete (#3092). Cyrillic script fixtures guard against mixed-language copy. Awaiting native-speaker review. |
64 | Ukrainian | `uk.json` | all | **shipped** | Complete (#4791). Cyrillic script fixtures keep it distinct from Russian (no ы/э/ъ; і/ї/є/ґ present). Awaiting native-speaker review. |
65
66 ## Website locales
67
68 The website derives routing, the switcher, sitemap, and hreflang from
69 `ALL_LOCALES` in `web/lib/i18n/config.ts` — one canonical registry, no
70 second taxonomy. **partial** locales route and are selectable with a
71 visible `(partial)` badge in the switcher; their dictionaries
72 (`web/lib/i18n/dictionaries/<code>/`) cover shared chrome (masthead, nav,
73 mobile menu, theme toggle, live ticker, footer, switcher) and the home page,
74 held to exact key parity with the English reference by
75 `npm run check:locales` and `web/lib/i18n/dictionaries.test.ts`.
76 Everything outside that scope renders the English page copy — a deliberate
77 fallback, never a dictionary key on screen.
78
79 **As of #4934 (v0.9.4) there is one dictionary path for every routed
80 locale, Chinese included.** `web/app/[locale]/page.tsx`,
81 `web/components/nav.tsx`, and `web/components/footer.tsx` no longer carry an
82 `isZh` / `foreign` copy branch: they read `getHome(locale)` and
83 `getChrome(locale)`. `web/lib/i18n/dictionaries/zh/` now exists (it used to
84 be inline TSX), and nav/footer link sets are generated once in
85 `web/lib/i18n/links.ts` so every locale gets the identical route shape.
86
87 **Website/docs translation pipeline (General Translation CLI, 2026-08-28).**
88 Runtime stays the dictionaries above — do not add `gt-next` beside them.
89 `web/gt-catalog/[locale].json` is the local JSON interchange (`en` + live
90 `zh` first). `npm run i18n:gt -- export` writes catalogs from dictionaries;
91 `check` (hooked from `check:locales`) requires them to match; `import`
92 writes reviewed JSON back to website dictionary TS only. `translate` is
93 fail-closed unless BYOK `GT_API_KEY` and `GT_PROJECT_ID` are set in the
94 environment — never commit those values, never point this config at
95 `crates/localization/locales`, and never wrap model completions. `gt generate` is
96 not used: it is a framework JSX scanner, not a JSON-catalog tool.
97 Reference shape: **`ChromeDict` 52 keys, `HomeDict` 62 keys.** Bilingual
98 secondary nav labels, the masthead seal and issue line, the ticker live
99 label, and the per-locale `Intl` date tag are dictionary values — no locale
100 renders another language's script by accident.
101
102 | Locale | Code | Status | Notes |
103 |--------|------|--------|-------|
104 | English | `en` | **shipped** | Source text and the reference dictionary shape. Every page has an EN route. |
105 | Simplified Chinese | `zh` | **shipped** | Full parity with EN on all first-class pages. Chrome + home are dictionary-backed (`dictionaries/zh/`) as of #4934; the remaining page bodies are still inline `{ en, zh }` content modules. |
106 | Japanese | `ja` | **partial** | #3091. Chrome + home page localized via dictionary; other page bodies/metadata fall back to English. |
107 | Vietnamese | `vi` | **partial** | #3091. Same scope as Japanese. |
108 | Korean | `ko` | **partial** | #3093. Same scope as Japanese. |
109 | Russian | `ru` | **partial** | #3092. Same scope as Japanese. |
110 | Ukrainian | `uk` | **partial** | #4791 — shipped alongside Russian, same scope. |
111 | Spanish | `es` | **partial** | #3093. Same scope as Japanese. |
112 | Brazilian Portuguese | `pt-BR` | **partial** | #3093. Same scope as Japanese. |
113 | French | `fr` | **planned** | #4788 — TUI pack available; website next wave. |
114 | German | `de` | **planned** | #4788 — TUI pack available; website next wave. |
115 | Catalan | `ca` | **planned** | #4749/#4788 — TUI pack available; website next wave. |
116 | Indonesian | `id` | **partial** | #4789. Same scope as Japanese. |
117 | Hindi | `hi` | **planned** | #4790 — TUI pack available; website next wave. |
118 | Arabic | `ar` | **deferred** | RTL candidate. Deferred until layout/typography QA exists (bidirectional text, mirrored chrome, number formatting). |
119
120 Every partial locale carries the full 52/62 key set (see
121 `npm run check:locales`); the chrome and home page are genuinely translated,
122 not English pass-through — `dictionaries.test.ts` fails on an English
123 prose value in a non-English pack. The localized strings are
124 machine-translated to the same standard as the rest of each pack and are
125 **awaiting native-speaker review**, consistent with the TUI packs above.
126
127 Remaining website scope for the partial locales (next wave): per-page body
128 copy and `generateMetadata` titles/descriptions beyond the home page, the
129 `{ en, zh }` shared-content modules under `web/lib/content/`, and the
130 TerminalPlayer scene excerpts in `web/components/thinking-trace.tsx`. The
131 dictionary layer, routing, hreflang, and switcher already cover them, so filling in a
132 page is a dictionary edit, not plumbing. That remaining English is exactly
133 what the `(partial)` badge is honest about.
134
135 ## README locales
136
137 | Locale | File | Status | Parity check |
138 |--------|------|--------|-------------|
139 | English | `README.md` | **shipped** | Canonical source |
140 | Simplified Chinese | `docs/i18n/README.zh-CN.md` | **shipped** | `scripts/check-readme-translations.py` (stamp + fences + URLs + sections) |
141 | Japanese | `docs/i18n/README.ja-JP.md` | **shipped** | Same |
142 | Vietnamese | `docs/i18n/README.vi.md` | **shipped** | Same |
143 | Korean | `docs/i18n/README.ko-KR.md` | **shipped** | Same |
144 | Latin American Spanish | `docs/i18n/README.es-419.md` | **shipped** | Same |
145 | Brazilian Portuguese | `docs/i18n/README.pt-BR.md` | **shipped** | Same |
146 | Russian | `docs/i18n/README.ru.md` | **shipped** | Same (#3092). Awaiting native-speaker review. |
147 | Ukrainian | `docs/i18n/README.uk.md` | **shipped** | Same (#4791). Awaiting native-speaker review. |
148 | Indonesian | `docs/i18n/README.id.md` | **shipped** | Same (#4789). Awaiting native-speaker review. |
149 | French | `docs/i18n/README.fr.md` | **shipped** | Same. Awaiting native-speaker review. |
150 | German | `docs/i18n/README.de.md` | **shipped** | Same. Awaiting native-speaker review. |
151 | Traditional Chinese | `docs/i18n/README.zh-TW.md` | **shipped** | Same. Awaiting native-speaker review. |
152 | Hindi | `docs/i18n/README.hi.md` | **shipped** | Same. Awaiting native-speaker review. |
153 | Turkish | `docs/i18n/README.tr.md` | **shipped** | Same. Awaiting native-speaker review. |
154 | Italian | `docs/i18n/README.it.md` | **shipped** | Same. Awaiting native-speaker review. |
155 | Polish | `docs/i18n/README.pl.md` | **shipped** | Same. Awaiting native-speaker review. |
156 | Arabic | `docs/i18n/README.ar.md` | **shipped** | Same. Awaiting native-speaker review. Markdown only; no HTML `dir` attributes. |
157 | Catalan | `docs/i18n/README.ca.md` | **shipped** | Same. Awaiting native-speaker review. |
158
159 ## Drift checks
160
161 | Check | Tool | Status |
162 |-------|------|--------|
163 | TUI pack key parity with `en.json` (complete packs) | `scripts/check-tui-locale-parity.py` + parity tests in `crates/localization/src/lib.rs` | **Shipped** (CI Lint job) |
164 | README translations stay in sync with `README.md` | `scripts/check-readme-translations.py` | **Shipped** (CI Lint job) |
165 | README locale links symmetric | `scripts/check-readme-locales.sh` | **Shipped** (CI Lint job) |
166 | Website dictionaries cover every routed locale except the `en` reference | `npm run check:locales` + `web/lib/i18n/dictionaries.test.ts` | **Shipped** (#3091, extended to `zh` in #4934) |
167 | No unmarked English prose survives in a non-English website dictionary | `leaves no unmarked English prose in any non-English dictionary` in `web/lib/i18n/dictionaries.test.ts` | **Shipped** (#4934) |
168 | Nav/footer routes stay in locale-swap parity for every routed locale | `web/lib/docs-ia.test.ts` over `web/lib/i18n/links.ts` | **Shipped** (#4934) |
169 | Accept-Language routes deterministically to all routed locales | `web/lib/i18n/detect.test.ts` (middleware delegates to `lib/i18n/detect.ts`) | **Shipped** (#3091) |
170 | Locale selector lists all routed locales with partial badges | `web/lib/i18n/config.test.ts` (switcher + router derive from one registry) | **Shipped** (#3091) |
171 | hreflang alternates cover every routed locale | `web/lib/page-meta.test.ts` | **Shipped** (#3091) |
172 | Cyrillic packs stay script-pure (no mixed-language copy, ru≠uk) | `cyrillic_packs_have_script_purity_and_no_mixed_language_fixtures` in `crates/localization/src/lib.rs` + `dictionaries.test.ts` | **Shipped** (#3092/#4791) |
173 | Devanagari grapheme-safe clip/wrap at 40/60/80 columns | `truncate_to_width_never_splits_devanagari_clusters` + width fixtures in `crates/localization/src/lib.rs` | **Shipped** (#4790) |
174 | Adding a UI locale never changes model-visible prompt bytes | `v092_locales_add_no_prompt_bookends_so_prompt_bytes_stay_stable` in `crates/engine/src/prompts.rs` | **Shipped** (cache-stability contract) |
175 | No shipped locale renders a missing-message marker | `no_shipped_locale_renders_a_missing_message_marker` in `crates/localization/src/lib.rs` | **Shipped** |
176
177 ## How to add a locale
178
179 A locale is not "added" until all three surfaces below either ship it or
180 carry an explicit `planned`/`partial`/`deferred` row in this matrix.
181
182 ### 1. TUI pack
183
184 1. Create `crates/localization/locales/<tag>.json` with every key in `en.json`,
185 following `crates/localization/locales/AGENTS.md` (placeholders stay literal;
186 product terms stay English per pack convention; preserve intentional
187 leading/trailing spaces).
188 2. Add the `Locale` variant plus its `tag`/`translation_target_name`/
189 `parse_locale`/`shipped`/`shipped_complete` arms in
190 `crates/localization/src/lib.rs`, and the `include_str!` arm in the
191 test module.
192 3. Wire the surfaces that still enumerate locales by hand. The `locale`
193 setting is a plain string row in `crates/config/src/settings_schema.rs`,
194 validated by `normalize_configured_locale` (which reuses `parse_locale`
195 from step 2), and the `/config` value list (`config_choice_values` in
196 `crates/tui/src/tui/views/mod.rs`) and hint text
197 (`configured_locale_values`) derive from `Locale::shipped()`, so those need
198 no edit. Review the setup wizard (`crates/tui/src/tui/setup/mod.rs`) and
199 `locale_display` in `crates/tui/src/commands/groups/config/config.rs` for
200 explicit locale mappings. Also review `public_site_locale_segment` in
201 `crates/tui/src/commands/groups/core/links.rs`: the portable `/links` command
202 matches locale tags, not the host `Locale` enum. Unlisted tags fall back to
203 English website pages, so the compiler will not flag a newly added locale
204 here. Add an explicit tag mapping when that locale is available on the website,
205 and verify `/links` selects the intended documentation/community URLs.
206 Add a `LANGUAGE_OPTIONS`
207 entry to the onboarding language picker
208 (`crates/tui/src/tui/onboarding/language.rs`); its
209 `picker_offers_every_shipped_locale` test fails until you do. Several no-English-leak tests
210 (for example in `status_picker.rs` and `tool_card.rs`) list locales
211 explicitly; add the new tag there when the pack is complete.
212 4. Run `python3 scripts/check-tui-locale-parity.py` and
213 `cargo test -p codewhale-tui localization`.
214 5. If the pack must ship incomplete, declare it partial: keep it out of
215 `shipped_complete()`, mark it in `is_partial_pack()`, and add it to
216 `PARTIAL_PACKS` in `scripts/check-tui-locale-parity.py` with a tracking
217 issue. No pack is partial today — `PARTIAL_PACKS` is empty and
218 `is_partial_pack()` returns false for every shipped locale — so a new
219 entry is the only thing that reopens the English-fallback path.
220
221 ### 2. README
222
223 1. Translate `README.md` into `docs/i18n/README.<tag>.md`, preserving structure,
224 commands, and the #3087 factual history.
225 2. Cross-link it from the language line in `README.md` and from the other
226 translated READMEs.
227 3. Restamp per `scripts/check-readme-translations.py`, then run
228 `python3 scripts/check-readme-translations.py` and
229 `bash scripts/check-readme-locales.sh`.
230
231 ### 3. Website
232
233 1. Add/flip the locale entry in `ALL_LOCALES` in `web/lib/i18n/config.ts` —
234 the switcher, routes, middleware, sitemap, and hreflang derive from it,
235 so no per-locale switcher edit is needed. Use the `partial` status for
236 locales that ship the chrome+home dictionary scope before full page
237 parity.
238 2. Create `web/lib/i18n/dictionaries/<code>/chrome.ts` and `home.ts`
239 following the English reference shape (`dictionaries/en/`).
240 3. Middleware detection needs no change for base tags; region variants and
241 base→variant mappings live in `web/lib/i18n/detect.ts`.
242 4. Run `cd web && npm run check:locales && npm test && npm run build`.
243
244 ### 4. Matrix
245
246 Update the TUI, README, and Website tables above — one row per surface,
247 with per-surface status.
248
249 ## Assessments
250
251 ### Galician (`gl`) and Basque (`eu`) — 2026-07-25, per #4749
252
253 Assessed alongside the Catalan pack (#4749 / #4788), which asked whether
254 Galician and Basque are "similar-value European additions" worth shipping
255 in the same wave.
256
257 **Decision: defer both.** Rationale:
258
259 - The case #4788 makes for Catalan is specifically that it "has an
260 unusually strong software-localization tradition and an active volunteer
261 community" — a review-capacity argument, not a market-size one. That
262 argument does not transfer: Galician and Basque have materially smaller
263 localization communities, so a pack for either would ship with no
264 realistic path to native-speaker review.
265 - Galician speakers have a workable fallback already: the shipped
266 `es-419` pack (and `pt-BR` is lexically close). Basque is a language
267 isolate with no fallback proximity — its per-string review cost is the
268 highest of the three, and machine-translated Basque is the least
269 trustworthy of the three.
270 - There is no natural "ship together" grouping: the v0.9.2 wave already
271 bundles the locales that share acceptance criteria (Latin-script
272 fr/de/ca/id, Cyrillic uk, Devanagari hi). gl/eu share only the
273 review-capacity constraint, which neither clears.
274
275 **Cost/demand evidence behind the decision:** a complete TUI pack is
276 1,299 keys (~8–12k words) plus an ongoing obligation to retranslate every
277 changed English string in lockstep — the parity gate makes silent drift a
278 CI failure, so an unmaintained pack is worse than none. No community
279 member has requested gl or eu (no issues, no PRs, no translations offered),
280 while the gl/eu base tags already route cleanly through
281 `web/middleware.ts` the day a champion appears. We do not ship packs we
282 cannot get natively reviewed, and we do not advertise unshipped packs.
283
284 Revisit when a native-speaker champion appears for either language, or if
285 Catalan uptake after v0.9.2 suggests demand. Both base tags (`gl`, `eu`)
286 route through `web/middleware.ts` with no middleware change when that
287 happens.
288
289 ## Related issues
290
291 - #3091 — Website parity with JA + VI README locales
292 - #3092 — Russian README + website localization
293 - #3093 — Korean, Spanish, Brazilian Portuguese next-wave locales
294 - #3087 — Post-rebrand README source text refresh
295 - #4057 — `zh-Hant` scoped as a partial TUI pack with English fallback
296 - #4787 — This matrix's TUI table + the locale-drift CI gates
297 - #4788 — French, German, Catalan TUI localization
298 - #4789 — Indonesian localization
299 - #4790 — Hindi localization + Devanagari terminal-shaping spike
300 - #4791 — Ukrainian localization alongside Russian
301 - #4749 — Catalan UI language + Galician/Basque assessment
302 - #5482 — EPIC(docs): review, partially restructure, and fully localize
303 documentation to Chinese
304
304 lines MARKDOWN