Skip to content

feat(i18n): add Traditional Chinese (zh-Hant) UI locale - #29795

Merged
OrcaWin merged 7 commits into
stablyai:mainfrom
oahsiao:feat/zh-hant-locale
Oct 28, 2026
Merged

OrcaWin merged 7 commits into
stablyai:mainfrom
oahsiao:feat/zh-hant-locale

Conversation

@oahsiao

@oahsiao oahsiao commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

ELI5

Orca's interface can now be displayed in Traditional Chinese. If your system language is zh-TW / zh-HK / zh-Hant, the app also starts in Traditional Chinese instead of English. The Traditional wording is derived from the existing reviewed Simplified catalog, so the two stay consistent.

What Changed

  • Added 繁體中文 to the UI language picker (renderer, main process, shared locale lists, settings search).
  • Added a generated catalog src/renderer/src/i18n/locales/zh-Hant.json (20,153 lines), produced from zh.json by config/scripts/generate-zh-hant-catalog.mjs: one OpenCC cn → twp pass, then 16 reviewed Taiwan-terminology fixes (e.g. 許可權→權限, 賬戶→帳戶) and a source-guided 進程→行程 fix. A --check mode is wired into verify:localization-catalogs, so editing zh.json without re-syncing fails CI. pnpm run sync:zh-hant-catalog regenerates.
  • Pinned load: 'currentOnly' on both i18next instances. With i18next's default, zh-Hant silently falls back to zh (Simplified) for any missing key; with this pin it falls back to English, which is the only correct fallback.
  • Fixed locale resolution: zh-TW / zh-HK / zh-Hant used to resolve to English (the default); they now resolve to zh-Hant. zh-MO added as a Traditional region. Bare zh still means Simplified.
  • Language-picker endonyms (e.g. 中文(简体)) are pinned so no locale ever renames another language in a script its own readers can't read.
  • New dependency: opencc-js@1.4.2 (locked, dev + build-time only; used by the generator, not shipped to the app runtime).

Why

Deriving from the Simplified catalog rather than translating from English afresh carries over the terminology and glossary decisions the Simplified catalog already settled, and keeps the two Chinese catalogs in lockstep via generation instead of manual drift. The corrections are explicit, reviewable table entries because OpenCC's Taiwan profile is not idempotent — iterating makes output worse (游標→遊標, 程序→程式) — so every deviation is a pinned, corpus-verified rule (hit counts from Microsoft's VS Code zh-Hant language pack recorded in comments). The currentOnly pin was chosen over fixing individual keys because i18next's locale-chain fallback is global: any single missing key would leak Simplified text into the Traditional UI.

Linked Issue

Fixes #10592

Visual Proof

N/A — no layout or interaction change; the picker gains one endonym entry and all other text comes from the generated catalog. Reviewers can switch Settings → Appearance → Language to 繁體中文 to see the translated UI.

Testing

  • Automated tests added/updated: config/scripts/generate-zh-hant-catalog.test.mjs (sync, key parity, placeholder preservation, no Simplified-only glyphs, Taiwan-term pins, endonym pins) plus updates to ui-locale, ui-language, catalog-nested-settings, appearance-search, browser-link-routing-localization, and provider-credit-balance-locales tests (53 tests pass).
  • verify:localization-catalogs, typecheck, and lint pass locally.

Steps to verify manually: run pnpm run verify:zh-hant-catalog (should pass), then switch the UI language to 繁體中文 and confirm the interface renders Traditional (e.g. 設定 → 權限 shows 權限, not 許可權).

AI Disclosure

Developed with AI assistance (Claude Code): catalog generation, tests, and wiring drafted by the model and reviewed by the human author.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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 stablyai#10592

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oahsiao
oahsiao requested a review from brennanb2025 as a code owner October 16, 2026 18:19
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 509ecc7d-8577-46f8-93ec-7d1c67d2ddbd
Commits

Reviewing files that changed from the base of the PR and between fa707b5 and 4b02d1a.

Files selected for processing: 2
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/shared/ui-locale.test.ts
Files with no reviewable changes: 1
  • src/shared/ui-locale.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Walkthrough

Adds Traditional Chinese (zh-Hant) as a supported UI language. Chinese locale tags with the Hant script or TW, HK, or MO region resolve to this locale. The main and renderer i18n instances can load its catalog, which contains translations across the application. Language settings, onboarding, appearance search, and locale labels now include the option.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 4b02d

The Traditional Chinese locale is ready to merge after normal checks. Native Taiwan terminology review can continue separately.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding the Traditional Chinese (zh-Hant) UI locale.
Description check Passed The description includes all required sections, explains the user-visible change and rationale, links issue #10592, provides visual-proof guidance, documents testing, and completes the checklist. Howe…
Linked Issues check Passed Issue #10592 requires a Traditional Chinese UI catalog, Traditional Chinese locale resolution, and no Simplified substitute for zh-TW and zh-HK users. Reviewed head evidence:

- Catalog: `src/renderer…
Out of Scope Changes check Passed Every changed file supports the Traditional Chinese locale requested by #10592:

- Locale and language logic: ui-locale.ts, ui-language.ts, their tests, and main-i18n-lazy-locale.test.ts.
- Rend…
Full details: Description check

Explanation

The description includes all required sections, explains the user-visible change and rationale, links issue #10592, provides visual-proof guidance, documents testing, and completes the checklist. However, it contains stale implementation details about OpenCC generation and the catalog-check hook that the PR objectives state were removed in favor of a hand-maintained catalog.

Full details: Linked Issues check

Explanation

Issue #10592 requires a Traditional Chinese UI catalog, Traditional Chinese locale resolution, and no Simplified substitute for zh-TW and zh-HK users. Reviewed head evidence:

  • Catalog: src/renderer/src/i18n/locales/zh-Hant.json exists (raw summary: about 18,011 lines). Per the maintainer report, it covers 16,266 of 16,277 keys. The 11 status-bar balance keys are intentionally absent. The issue does not require full key coverage.
  • Locale resolution: src/shared/ui-locale.ts adds 'zh-Hant' to SUPPORTED_UI_LOCALES. matchUiLocale maps Hant script and TW, HK, MO regions to zh-Hant. Hans and other regions map to zh. resolveUiLocale maps UI_LANGUAGE_CHINESE_TRADITIONAL to zh-Hant.
  • Loaders: src/renderer/src/i18n/i18n.ts adds 'zh-Hant' to NON_DEFAULT_LOCALE_URLS. The raw summary reports the same loader addition in src/main/i18n/main-i18n.ts.
  • Fallback: both i18next instances set load: 'currentOnly'. The code comment states that the default expansion would render Simplified text for missing zh-Hant keys. Missing keys therefore fall back to English.
  • Language choices and search: UI_LANGUAGE_CHINESE_TRADITIONAL = 'zh-Hant' is added in src/shared/ui-language.ts. Picker, fallback label 繁體中文(台灣), and appearance-search.ts keywords are added.
  • Tests: the raw summary reports tests for locale normalization, system-locale resolution, lazy loading, the Traditional selection, and English fallback for a Simplified-only key.

I inspected ui-locale.ts and i18n.ts at head. They match the summary. The PR description still describes a generator and OpenCC dependency. The raw summary lists no such files, and the PR objectives state they were removed. This stale description does not change the requirement result. Native Taiwan terminology review remains open. It is a review task, not a coding requirement of the issue.

Full details: Out of Scope Changes check

Explanation

Every changed file supports the Traditional Chinese locale requested by #10592:

  • Locale and language logic: ui-locale.ts, ui-language.ts, their tests, and main-i18n-lazy-locale.test.ts.
  • Renderer loading and picker: i18n.ts, supported-languages.ts, appearance-search.ts, lazy-locale.test.ts, and OnboardingLanguageSwitcher.test.tsx. The onboarding test change updates the option count from seven to eight.
  • Label entries in existing locale catalogs (en.json, zh.json, es.json, fr.json, ja.json, ko.json, pt.json) and config/scripts/locale-translation-policy.mjs. These add the picker label 繁體中文(台灣) for each UI language.
  • config/vitest.config.ts: the locale-catalog test asset loader now accepts uppercase filenames, which zh-Hant.json requires.
  • docs/site/content/docs/settings.mdx: documents the new language option.
  • config/i18n-traditional-chinese.md: a terminology and maintenance guide for the new catalog.

No changed file lacks a connection to the requested locale. The raw summary shows no unrelated refactor or dependency change. The generator and OpenCC dependency described in the PR body are absent from the summary, so they are not out-of-scope changes at head.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 13 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9e31338-8c91-422e-adfc-980294ec1d28
📥 Commits

Reviewing files that changed from the base of the PR and between 10a8ecf and 3589081.

⛔ Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 28
  • .gitattributes
  • config/scripts/generate-zh-hant-catalog.mjs
  • config/scripts/generate-zh-hant-catalog.test.mjs
  • config/scripts/locale-translation-policy.mjs
  • config/scripts/locale-zht-key-overrides.mjs
  • config/scripts/locale-zht-value-overrides.mjs
  • config/scripts/verify-localization-catalogs.mjs
  • config/scripts/zh-hant-catalog.mjs
  • package.json
  • src/main/i18n/main-i18n.ts
  • src/renderer/src/components/settings/appearance-search.test.ts
  • src/renderer/src/components/settings/appearance-search.ts
  • src/renderer/src/components/settings/browser-link-routing-localization.test.ts
  • src/renderer/src/i18n/catalog-nested-settings.test.ts
  • src/renderer/src/i18n/i18n.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/provider-credit-balance-locales.test.ts
  • src/renderer/src/i18n/supported-languages.ts
  • src/shared/ui-language.test.ts
  • src/shared/ui-language.ts
  • src/shared/ui-locale.test.ts
  • src/shared/ui-locale.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

oahsiao and others added 3 commits October 17, 2026 14:22
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 <noreply@anthropic.com>
…n 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 stablyai#22402 (which carries stablyai#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 <84211143+hungchihsueh@users.noreply.github.com>
Co-authored-by: chilung-cgu <b0423031@gmail.com>
@OrcaWin

OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Maintainer update, pushed to this branch (merge of main plus e3a0f39). Thanks @oahsiao. This is now the Traditional Chinese PR we plan to land.

What changed from the original version

  • The OpenCC generator is gone. That means opencc-js, generate-zh-hant-catalog*, the locale-zht-* overrides and the --check hook in verify:localization-catalogs are removed. zh-Hant.json is now maintained by hand like pt, fr and the other built-ins. Converting zh text carried mainland terms into the catalog (智慧體, 會話, 倉庫, 標籤頁).
  • Catalog. I rebuilt it against the current en.json (after chore(i18n): gate unreferenced catalog keys in the extraction check and retire 1,644 of them #22056 and fix(i18n): resolve count strings with each language's plural rules #34693):
  • Label. The language is labeled 繁體中文(台灣) in every catalog, the language picker, onboarding and settings search.
  • Detection. zh-TW, zh-HK, zh-MO and zh-Hant* map to zh-Hant. zh, zh-CN, zh-SG and zh-Hans* stay on zh. Unknown scripts are still unsupported.
  • load: 'currentOnly' is kept in both i18next instances. A renderer test now checks that missing keys fall back to English, not Simplified.

Supersedes #22402, #14223, #10604, #7801, #9360, #25089 and #8923. Thanks to everyone who worked on Traditional Chinese.

…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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 2
src/main/i18n/main-i18n-lazy-locale.test.ts: 1

63-65: Trivial · Functional Correctness · Quick win

Add a missing-key fallback assertion for the main i18next instance.

The current menu.file assertion does not exercise a key absent from zh-Hant. mainI18n is exported and can accept a test-only Simplified Chinese resource. Add this assertion to detect a regression that makes zh-Hant fall back to zh instead of English.

Suggested fix
+  it('does not fall back to Simplified Chinese for missing Traditional Chinese keys', async () => {
+    mainI18n.addResourceBundle(
+      'zh',
+      'translation',
+      { mainFallbackProbeOnlyInZh: '简体中文' },
+      true,
+      true
+    )
+    await setMainUiLanguage(UI_LANGUAGE_CHINESE_TRADITIONAL)
+    expect(translateMain('mainFallbackProbeOnlyInZh', 'English fallback')).toBe('English fallback')
+  })
+
   it('uses caller English when a target catalog omits a key', async () => {
src/renderer/src/i18n/lazy-locale.test.ts: 1

42-49: Trivial · Maintainability & Code Quality · Quick win

Assert a real missing catalog key without an inline default.

zhOnlyKey returns its supplied defaultValue, so this test can pass even if English fallback stops working. browser.loadFailure.blockedTitle is a real English entry, is absent from zh-Hant, and is already present in the eager English fixture. Assert it without injecting another English resource:

Suggested fix
     expect(i18n.t('menu.file', { defaultValue: 'File' })).not.toBe('File')
     expect(i18n.t('zhOnlyKey', { defaultValue: 'English' })).toBe('English')
+    expect(i18n.t('browser.loadFailure.blockedTitle', { host: 'example.com' })).toBe(
+      'example.com is blocked'
+    )

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca687708-e712-439d-a759-13983d69d24e
Commits

Reviewing files that changed from the base of the PR and between 6e5997d and e3a0f39.

Files selected for processing: 23
  • config/i18n-traditional-chinese.md
  • config/scripts/locale-translation-policy.mjs
  • config/vitest.config.ts
  • docs/site/content/docs/settings.mdx
  • src/main/i18n/main-i18n-lazy-locale.test.ts
  • src/main/i18n/main-i18n.ts
  • src/renderer/src/components/onboarding/OnboardingLanguageSwitcher.test.tsx
  • src/renderer/src/components/settings/appearance-search.ts
  • src/renderer/src/i18n/i18n.ts
  • src/renderer/src/i18n/lazy-locale.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/supported-languages.ts
  • src/shared/ui-language.test.ts
  • src/shared/ui-language.ts
  • src/shared/ui-locale.test.ts
  • src/shared/ui-locale.ts
Files skipped from review as they are similar to previous changes: 6
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/en.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

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.
@OrcaWin

OrcaWin commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Maintainer follow-up on top of the earlier update (pushed as 22303ef2c59 and fa707b50294):

  • Catalog complete: translated the remaining 2,043 keys that were added to en.json after this branch started. zh-Hant.json now covers 16,266/16,277 keys, the same coverage as zh.json. The 11 status-bar balance keys are left out on purpose, as they are in zh.
  • Full-catalog review: used machine-assisted translation review, with two independent passes per key and a final cross-check of every accepted edit. This applied 629 corrections: 30 meaning or untranslated-text fixes, and 599 glossary and phrasing fixes, mostly 終端機, 用量 and API 金鑰, plus clearer counts and actions. Reviewer suggestions that went against the wording the catalog already uses were not applied. For example, shell, Fork and right-click shortcuts are unchanged.
  • Glossary: added rows to config/i18n-traditional-chinese.md for skill, automation, workflow, review, diff, stash, sidebar, browser, usage, quota, dictation, shortcut, prompt, context, token, credential, notification, thread, schedule and emulator.

The localization catalog, extraction, coverage and runtime-catalog checks pass, as do tc:web, tc:node and the i18n, onboarding and appearance tests. A native Taiwan reviewer should still sign off on the terminology, especially 代理程式, 工作階段 and 存放庫.

@OrcaWin
OrcaWin merged commit b62f9bf into stablyai:main Oct 28, 2026
46 checks passed
tomarai85 added a commit to tomarai85/orca that referenced this pull request Oct 28, 2026
Drop TabGroupDropOverlay.paneColumnLabel from the ru, tr and zh-Hant
catalogs main added (stablyai#29795, stablyai#34717, stablyai#34718). This PR removes the
string and its seven other translations, and the catalog check fails
on a key that en.json no longer has.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Traditional Chinese (zh-Hant) UI locale

2 participants