Repository navigation
feat(i18n): add zh-TW (Traditional Chinese) locale - #14223
chilung-cgu wants to merge 5 commits into
Conversation
Adds Traditional Chinese as a selectable UI language and wires it through both the renderer and the main process. ## What - `src/renderer/src/i18n/locales/zh-TW.json` — 11,794-entry catalog. - `zh-TW` registered in `SUPPORTED_UI_LOCALES`, `BuiltInUiLanguage`, the language picker, and the lazy locale loaders on both sides of the IPC border. - `normalizeSupportedUiLocale` now maps the Traditional-script system locales (`zh-TW`, `zh-HK`, `zh-MO`, `zh-Hant*`) to `zh-TW`; every other `zh-*` tag still resolves to the Simplified catalog. Before this change they all fell back to English. - `settings.appearance.language.traditionalChinese` added to en/zh/ja/ko/es so the option is labelled in every locale, not only in zh-TW itself. en.json is the source of truth for `verify-localization-catalog`, so a zh-TW-only key fails the lint gate. ## Translation quality The catalog started as a script conversion of zh.json, so it carried the usual OpenCC phrase-table damage and a lot of Mainland vocabulary. Both are fixed: - Over-converted words (Traditional glyphs, wrong term): 許可權→權限, 全域性→全域, 型別→類型, 控制元件→控制項, 高階→進階, 引數→參數, 釋出→發布, 進位制→進位, 賬→帳, 臺→台, 例項, 對映, 映象, 擴充套件, 首選項, 稽核, 只讀→唯讀. - Taiwan usage: 本地→本機, 評審→審查, 倉庫→存放庫, 配置→設定, 選項卡/標籤頁→分頁, 訪問→存取, 當前→目前, 計算機→電腦, 程序→行程, 匹配→符合, 後台→背景, 更改→變更, 自定義→自訂, 地址→位址, 身份→身分, 重置→重設, 禁用→停用, 構建→建置, 埠→連接埠. 存放庫 and 連接埠 follow the VS Code / GitHub zh-TW UI. - Terms Taiwan developers keep in English are no longer translated: Token, fast-forward, Agent, Session, Clone. - Outright mistranslations: "Mermaid Diagram" rendered as "M z圖", five "on SSH host" labels had dropped SSH, both "Grab" and "Hold" became 抓住, and Git URL / Git Username lost the brand casing. - Running the repo's own repair policy over the catalog restored 39 code literals that machine translation had localized (MD→醫學博士, PLAN.md→計劃.md, /pricing→/定價, throw src/auth→丟擲 src/auth) and re-spaced 97 CJK/Latin runs. ## Toolchain zh-TW is registered with the localization policy so `sync:localization-catalog` maintains it rather than reverting it: generic-term renderings, brand mistranslations, `NATIVE_PICKER_LABELS`, and the CJK/Latin spacing locale list. zh-TW has zero drift against `repairTranslatedValue` (zh currently has 648). `NATIVE_PICKER_LABELS` is now a single shared object, since the language endonyms are identical in every catalog and must never be script-converted — that is what kept 中文(简体) Simplified inside the Traditional catalog. A zh-TW key override was added for the two bare "Cursor" labels that name the on-screen cursor: `NEVER_TRANSLATE_VALUES` pins the value to English before `isScreenCursorContext` can exempt it. ## Tests - `zh-tw-traditional-usage.test.ts` gates the script (no Simplified-only characters outside the Simplified endonym) and the glossary, so neither pasted Simplified text nor a reverted term can land unnoticed. - The renderer and main lazy-loader specs assert zh-TW serves 檔案 rather than falling back to the zh catalog's 文件 — zh-TW is the only region-tagged loader key, so an i18next code-formatting or fallback-hierarchy regression would otherwise be silent. - zh-TW added to the locale lists in the link-routing localization spec, the repair-catalog missing-leaves spec, and the macOS TCC repair-idempotence spec. Co-Authored-By: Claude Opus 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds Traditional Chinese as a built-in UI language with Mergeability Score: 🔵 Low · up to The PR adds Traditional Chinese support and is otherwise mergeable, but the localization repair rules may misclassify unrelated words such as “report” as repository terms during future catalog maintenance, potentially producing incorrect translations; this should remain an explicit follow-up for the owner. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/i18n/zh-tw-traditional-usage.test.ts (1)
1-10: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReduce the introductory comment.
Keep one brief comment for the non-obvious policy rationale. Remove the test-mechanics explanation.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 65fa2cd3-25c2-4c29-b5ae-23e1247b0d90
📒 Files selected for processing (23)
config/scripts/locale-brand-mistranslations.mjsconfig/scripts/locale-generic-ui-terms.mjsconfig/scripts/locale-key-overrides.mjsconfig/scripts/locale-repair-catalog-missing-leaves.test.mjsconfig/scripts/locale-translation-policy.mjsconfig/scripts/macos-tcc-prompt-localization.test.mjssrc/main/i18n/main-i18n-lazy-locale.test.tssrc/main/i18n/main-i18n.tssrc/renderer/src/components/settings/browser-link-routing-localization.test.tssrc/renderer/src/i18n/i18n.tssrc/renderer/src/i18n/lazy-locale.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh-TW.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/i18n/supported-languages.tssrc/renderer/src/i18n/zh-tw-traditional-usage.test.tssrc/shared/ui-language.test.tssrc/shared/ui-language.tssrc/shared/ui-locale.test.tssrc/shared/ui-locale.ts
There was a problem hiding this comment.
Pull request overview
Adds a new Traditional Chinese (zh-TW) UI locale and wires it through shared locale resolution, renderer/main lazy-loading, localization repair policy, and regression tests so Traditional-script system locales map to zh-TW instead of falling back to English.
Changes:
- Register
zh-TWacross shared locale normalization/resolution and renderer/main i18n lazy loaders. - Add the new
zh-TWcatalog and extend existing catalogs with atraditionalChineselanguage-picker label key. - Extend localization toolchain policies + add regression tests (including a zh-TW terminology/script gate) to prevent catalog drift.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/shared/ui-locale.ts | Add zh-TW to supported locales; map Traditional-script locale tags to zh-TW. |
| src/shared/ui-locale.test.ts | Add coverage for Traditional Chinese mapping and explicit language resolution. |
| src/shared/ui-language.ts | Introduce UI_LANGUAGE_TRADITIONAL_CHINESE and include in built-in language set. |
| src/shared/ui-language.test.ts | Add normalization test for Traditional Chinese language value. |
| src/renderer/src/i18n/locales/zh-TW.json | New Traditional Chinese translation catalog (lazy-loaded). |
| src/renderer/src/i18n/zh-tw-traditional-usage.test.ts | Add zh-TW script/terminology gate to prevent Simplified glyphs and forbidden terms. |
| src/renderer/src/i18n/supported-languages.ts | Add Traditional Chinese to language picker choices and fallback labels. |
| src/renderer/src/i18n/locales/en.json | Add traditionalChinese label key for language picker. |
| src/renderer/src/i18n/locales/zh.json | Add traditionalChinese label key for language picker. |
| src/renderer/src/i18n/locales/ko.json | Add traditionalChinese label key for language picker. |
| src/renderer/src/i18n/locales/ja.json | Add traditionalChinese label key for language picker. |
| src/renderer/src/i18n/locales/es.json | Add traditionalChinese label key for language picker. |
| src/renderer/src/i18n/i18n.ts | Add zh-TW lazy loader in renderer i18n backend. |
| src/renderer/src/i18n/lazy-locale.test.ts | Add renderer test ensuring zh-TW doesn’t fall back to zh. |
| src/renderer/src/components/settings/browser-link-routing-localization.test.ts | Include zh-TW in non-English locale coverage set. |
| src/main/i18n/main-i18n.ts | Add zh-TW lazy loader in main-process i18n backend. |
| src/main/i18n/main-i18n-lazy-locale.test.ts | Add main-process test ensuring zh-TW doesn’t fall back to zh. |
| config/scripts/locale-translation-policy.mjs | Register zh-TW in picker label pinning and CJK/Latin spacing pass. |
| config/scripts/locale-repair-catalog-missing-leaves.test.mjs | Include zh-TW in repair-catalog missing-leaves test coverage. |
| config/scripts/macos-tcc-prompt-localization.test.mjs | Include zh-TW in macOS TCC prompt localization policy test coverage. |
| config/scripts/locale-key-overrides.mjs | Add zh-TW key overrides for “Cursor” (screen cursor context). |
| config/scripts/locale-generic-ui-terms.mjs | Add/extend canonical generic-term renderings for zh-TW. |
| config/scripts/locale-brand-mistranslations.mjs | Add zh-TW brand mistranslation mapping list for repair policy. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot review: the Repo generic renderings listed 倉庫 as an acceptable zh-TW form while zh-tw-traditional-usage.test.ts rejects it, so repairTranslatedValue would preserve Mainland wording that the gate then fails on. Added zh-TW phrase fixes that rewrite 倉庫/儲存庫 to 存放庫 when the English mentions a repo. The generic renderings intentionally keep both forms so the brand revert leaves them translated rather than rewriting them to Latin — the phrase fix, which runs after it, is what normalizes them. repair now returns 存放庫 for both, so the policy and the gate agree on the output. Cross-checked all 47 gated terms against the generic-term, brand, value, key-override and phrase-fix tables: 倉庫 was the only contradiction. 智慧體 is consistent, since the brand table reverts it to Agent, which is what the gate wants. Also gated 儲存庫, which the test had missed. CodeRabbit review: trimmed the test's file header to one comment per the repo comment guidance. Tests: pnpm lint passes; i18n/shared/config suites pass; zh-TW policy drift stays at 0. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 97df8726-0e55-4328-a767-8ede71b2b6f0
📒 Files selected for processing (2)
config/scripts/locale-phrase-fixes.mjssrc/renderer/src/i18n/zh-tw-traditional-usage.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/i18n/zh-tw-traditional-usage.test.ts
* feat(i18n): add Traditional Chinese (zh-Hant) UI locale Adds 繁體中文 as a selectable UI language and derives its catalog from zh.json rather than translating English afresh, so the reviewed Simplified terminology and Orca glossary decisions carry over. The conversion needed three corrections beyond OpenCC's `cn -> twp`: - One pass only. `twp`'s phrase dictionary is not idempotent (it maps 進程->程序 and 程序->程式), and iterating to a fixed point makes output worse: it rewrites the correct Taiwan 游標 to 遊標, and 程序 to 程式 where the source meant an OS process. - 16 terms where `twp` emits a form Taiwan does not use, each confirmed against Microsoft's VS Code zh-Hant language pack (許可權 0 vs 權限 84, 賬戶 0 vs 帳戶 111, and so on). - 進程 vs 程序 collapse in `twp` output. Taiwan calls an OS process 行程, so the generator consults the Simplified source to disambiguate; daemon copy reads 守護行程, not 守護程式. Also pins `load: 'currentOnly'` on both i18next instances. i18next's default expands `zh-Hant` into ['zh-Hant', 'zh', 'en'], so a key missing from the Traditional catalog would silently render Simplified. zh-Hant.json is generated and compared byte-for-byte, so the new check is wired into verify:localization-catalogs to fail when a Simplified edit skips regeneration. Refs #10592 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(i18n): fail the zh-Hant check on an unreadable zh.json The generator caught every error from reading and parsing zh.json, so a malformed or unreadable Simplified catalog logged "absent here" and exited 0 without ever comparing the generated Traditional catalog. Only ENOENT means there is nothing to derive, so every other failure now propagates. Tests cover the three paths the catch was conflating: an absent zh.json still passes for the combined verifier's synthetic fixtures, malformed JSON throws, and a directory where the catalog belongs throws EISDIR rather than reporting the file as missing. Co-Authored-By: Claude Code <[email protected]> * feat(i18n): ship Traditional Chinese (Taiwan) as a maintained built-in catalog Keeps the zh-Hant locale from this PR and makes it a hand-maintained catalog like the other built-ins, without the OpenCC generator: - Catalog reconciled with current en.json. Per key it prefers the Taiwan-reviewed copy from #22402 (which carries #14223), falls back to the zh-derived copy here, and drops entries whose English changed. A review pass then applied Taiwan terms (代理程式, 工作階段, 存放庫, 分頁, 列/欄) and 「」 quotes. Glossary: config/i18n-traditional-chinese.md. - Label 繁體中文(台灣)in every catalog, the picker, onboarding and search. - Detection maps zh-TW/zh-HK/zh-MO/zh-Hant* to zh-Hant; zh-CN/zh-SG/zh-Hans stay on zh. Both i18next instances use load: 'currentOnly' so missing keys fall back to English, not Simplified. - Drops opencc-js, the generator scripts and their verify hook. Co-authored-by: hungchihsueh <[email protected]> Co-authored-by: chilung-cgu <[email protected]> * feat(i18n): translate remaining Traditional Chinese (Taiwan) catalog keys Fill the 2,043 keys added to en since the source PRs branched, following the Taiwan glossary, and extend the glossary with skill, automation, usage, review, token and related terms. * fix(i18n): review Traditional Chinese (Taiwan) catalog wording Apply 629 reviewed corrections across the full catalog: 30 meaning or untranslated-text fixes and 599 glossary and phrasing fixes (終端機, 用量, API 金鑰, clearer counts and actions). Each edit was cross-checked by an independent review pass. * fix(i18n): polish sampled zh-Hant strings and drop redundant locale test Co-authored-by: Claude <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: OrcaWin <[email protected]> Co-authored-by: hungchihsueh <[email protected]> Co-authored-by: chilung-cgu <[email protected]>
|
Thank you for this! Traditional Chinese (Taiwan) is now a built-in UI language as of #29795: 繁體中文(台灣) in Settings → Appearance → Language. It's picked automatically for zh-TW, zh-HK, zh-MO and zh-Hant system locales, while zh-CN, zh-SG and zh-Hans stay on Simplified. Your work here fed into the terminology choices, including Taiwan wording like 電腦 and 分頁. Closing this one in favor of that PR. If you spot wording that reads wrong to a Taiwanese user, a follow-up PR against |
ELI5
Orca can now run its interface in Traditional Chinese. If your system is set to Taiwan, Hong Kong, or Macau, you get it automatically instead of falling back to English, and you can also pick 繁體中文 from Settings → Appearance → Language.
What Changed
The locale
src/renderer/src/i18n/locales/zh-TW.json(11,794 entries — the highest coverage of any non-English catalog).zh-TWregistered inSUPPORTED_UI_LOCALES,BuiltInUiLanguage, the language picker, and the lazy locale loaders on both sides of the IPC border (rendereri18n.tsand mainmain-i18n.ts).normalizeSupportedUiLocalemaps the Traditional-script system locales (zh-TW,zh-HK,zh-MO,zh-Hant*) tozh-TW. Every otherzh-*tag still resolves to the Simplified catalog. Before this change all four fell back to English.settings.appearance.language.traditionalChineseadded to en/zh/ja/ko/es as well, so the new option is labelled in every locale.en.jsonis the source of truth forverify-localization-catalog, so a zh-TW-only key fails the lint gate.Translation quality
The catalog began as a script conversion of
zh.json, which carries two failure modes that key-parity checks cannot see. Both are fixed:許可權→權限,全域性→全域,型別→類型,控制元件→控制項,高階→進階,引數→參數,釋出→發布,進位制→進位,賬→帳,臺→台, plus例項,對映,映象,擴充套件,首選項,稽核,只讀→唯讀.本地→本機,評審→審查,倉庫→存放庫,配置→設定,選項卡/標籤頁→分頁,訪問→存取,當前→目前,計算機→電腦,程序→行程,匹配→符合,後台→背景,更改→變更,自定義→自訂,地址→位址,身份→身分,重置→重設,禁用→停用,構建→建置,埠→連接埠.存放庫and連接埠follow the VS Code / GitHub zh-TW UI.M z圖; fiveon SSH hostlabels had dropped SSH entirely; both "Grab" and "Hold" became抓住;Git URL/Git Usernamelost the brand casing.MD→醫學博士,PLAN.md→計劃.md,/pricing→/定價,throw src/auth→丟擲 src/auth— and re-spaced 97 CJK/Latin runs.Toolchain registration
zh-TW is registered with the localization policy so
sync:localization-catalogmaintains the catalog instead of reverting it: generic-term renderings, brand mistranslations,NATIVE_PICKER_LABELS, and the CJK/Latin spacing locale list. zh-TW now has zero drift againstrepairTranslatedValue.NATIVE_PICKER_LABELSbecame a single shared object, because the language endonyms are identical in every catalog and must never be script-converted — that is what keeps中文(简体)Simplified inside the Traditional catalog.A zh-TW key override was added for the two bare
"Cursor"labels that name the on-screen cursor:NEVER_TRANSLATE_VALUESpins the value to English beforeisScreenCursorContextgets a chance to exempt it.Why
Traditional Chinese users previously got English.
normalizeSupportedUiLocaleexplicitly routedzh-TW/zh-HK/zh-Hantto the default locale rather than to the Simplified catalog — a deliberate placeholder (the old test was literally named "does not map Traditional Chinese to Simplified yet"), because Simplified text in a Traditional UI is worse than English.A machine conversion of
zh.jsonalone would not have been shippable: it produces text that is technically Traditional but reads as Mainland Chinese, and OpenCC phrase tables silently corrupt terms (权限→許可權, which is not a word). Neither problem is visible toverify-localization-catalog, which is why this PR also adds a gate for it.Linked Issue
No tracking issue exists for this. Happy to open one if the project prefers — this is a self-contained locale addition with no behavior change for existing locales.
Fixes #
Visual Proof
N/Afor existing locales — no rendering or behavior change for en/zh/ja/ko/es. The only shared-surface edit is one added key per catalog (the繁體中文picker label).For the new locale, screenshots of the rendered app in
zh-TWare attached below by the author (Settings → Appearance with the language picker, the terminal pane, and the workbench).Testing
Verified on macOS. Not exercised on Linux, Windows, or SSH — but the change is a locale catalog plus locale-tag normalization, with no platform-conditional code paths.
Automated
pnpm lint— passes, including all five localization verifiers.pnpm typecheck— passes.pnpm testforsrc/shared,src/renderer/src/i18n,src/main/i18n,config/scripts,src/renderer/src/components/settings— 6,438 passed, 0 failed.zh-tw-traditional-usage.test.tsgates the script (no Simplified-only characters outside the Simplified endonym) and the glossary, so neither pasted Simplified text nor a reverted term can land unnoticed. The gate was verified to actually fail by injecting each of its four violation classes.檔案rather than falling back to the zh catalog's文件. zh-TW is the only region-tagged loader key, so an i18next code-formatting or fallback-hierarchy regression would otherwise be silent.Manual
Driven in the running Electron app through Playwright CDP: the picker shows
繁體中文, the catalog renders across the workbench and settings panes, and zero elements clip —scrollWidth > clientWidthwas measured across every leaf node, which matters becauseAgent/Sessionreverting to English changed label widths.electron-vite buildin both--mode e2eand production mode emitszh-TWas its own lazy chunk, so the catalog is not pulled into the startup bundle.Not done: full
pnpm build(the native-module half was not run).AI Disclosure
Claude Opus 5 (Claude Code) was used to audit the machine-converted catalog, apply the terminology corrections, register the locale with the localization toolchain, and write the regression tests. Every claim above is backed by a command that was actually run; the terminology decisions follow the VS Code / GitHub zh-TW UI and this repo's own
NEVER_TRANSLATE_VALUESpolicy.Review
_-normalized before matching, so Windowszh_TWforms resolve correctly (covered by a test).zh-TWis registered in the main process loader as well, so menus, tray, and dialogs on a remote-backed workspace localize identically to the renderer.uiLanguageofzhstill resolves tozh; no existing preference changes meaning.load: 'all'means a zh-TW user also loadszhas a fallback layer; keys present in both are unaffected, but a key added tozhand notzh-TWwould surface as Simplified rather than English. Called out rather than changed, sinceloadis a global setting.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — lint/typecheck/test pass locally; fullpnpm buildnot runFollow-ups (not in this PR)
zh.jsoncarries the same translated-code-literal defects (MD→医学博士,PLAN.md→计划.md, and ~648 entries the repair policy would rewrite). Left alone to keep this PR focused.worktreeJumpPalette.filter.projectsis missing from every non-English catalog, so that sidebar header renders English in es/ja/ko/zh too. Added for zh-TW here; the cross-locale gap remains.