orca icon indicating copy to clipboard operation
orca copied to clipboard

feat(i18n): add traditional chinese (zh-tw) ui language

Open eviannaive opened this issue 4 months ago • 5 comments

Summary

Adds Traditional Chinese (中文(繁體), zh-TW) as a UI language.

  • New zh-TW locale in the language picker (Settings → Appearance → Language).
  • System locales zh-TW / zh-HK / zh-MO / zh-Hant now resolve to the Traditional catalog instead of falling back to English.
  • The catalog is derived from the curated Simplified catalog via OpenCC (cn→twp, Taiwan phrasing: 软件→軟體, 文件→檔案) with the new pnpm run bootstrap:zh-tw-catalog — deterministic, offline, byte-reproducible, and it inherits every existing glossary/brand repair instead of re-machine-translating ~10k strings from English.
  • pnpm run repair:locale-catalog regenerates zh-TW right after zh, keeping the locale inside the standard maintenance flow.
  • Catalogs stay lazy: zh-TW bundles as its own chunk, and load: 'currentOnly' keeps a zh-TW session from also fetching the Simplified catalog.

Screenshots

orca01 orca002

Testing

  • [x] pnpm lint — all steps pass except lint:switch-exhaustiveness, which already fails on main in source-control-manual-review-url.ts (unrelated file, predates this PR)
  • [x] pnpm typecheck
  • [x] pnpm test — full vitest suite diffed against a clean HEAD baseline: zero regressions (the only failures are local-environment ones identical on the baseline)
  • [x] pnpm build — zh-TW-*.js emitted as its own lazy chunk
  • [x] pnpm run verify:localization-catalog — 10,190-key parity across all six catalogs
  • [x] Manual (macOS): picker switch, native menu bar localization, system-locale detection, persistence across restart
  • [x] Added or updated high-quality tests that would catch regressions: locale resolution (zh-TW/zh-HK/zh-MO/zh-Hant), lazy catalog loading (renderer + Electron main), and the settings language picker option.

AI Review Report

AI review (8 angles: line-by-line, removed-behavior audit, cross-file trace, reuse, simplification, efficiency, altitude, conventions; adversarially verified) checked:

  • Cross-platform compatibility for macOS, Linux, and Windows: no platform-coupled logic; build scripts use path.join; no shortcuts, labels, or shell behavior changed.
  • SSH/remote/local compatibility: no assumptions about local execution; catalogs ship with the renderer/main bundles regardless of workspace backing.
  • Supported agent and integration compatibility: brand and product names (Orca, Claude, Codex, GitLab, Jira, …) are protected from translation by the policy tables, with a zh-TW-specific mistranslation table.
  • Performance risk: startup untouched (lazy chunk verified in build output); load: 'currentOnly' verified behavior-neutral for existing locales against i18next source; reviewer-found waste in the bootstrap script (double repair pass, per-call regex compilation) was fixed.
  • UI quality: native-label picker rendering verified in all six catalogs; full-scan shows zero Simplified-character leftovers and intact {{placeholders}}.

Review-found maintainability issues (zh-TW missing from the repair pipeline, duplicated CJK-spacing guards, copy-pasted menu-label repairs) were fixed in this PR.

Security Audit

AI security review found no new input handling, command execution, auth, secrets, IPC, or path handling risks. One new devDependency (opencc-js) is used at build time only; runtime changes are catalog data and locale resolution. No follow-up security work needed.

Notes

  • Depends on #7800 (its commit is included in this branch; will rebase once it merges).
  • Platform notes: none; behavior identical across macOS/Linux/Windows.
  • Remote/SSH notes: compatible with local and SSH-backed workspaces.
  • Git provider notes: no provider-specific behavior.
  • X/Twitter handle: not provided.

ELI5

Traditional Chinese (zh-TW) is a full UI language, including system locales like Hong Kong/Macau. The catalog is generated from Simplified Chinese with Taiwan phrasing.

eviannaive avatar Jul 08 '26 09:07 eviannaive

[!CAUTION]

Review failed

An error occurred during the review process. Please try again later.


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[bot] avatar Jul 08 '26 09:07 coderabbitai[bot]

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds Traditional Chinese (zh-TW) as a supported UI language. Shared locale utilities gain a new constant and normalization/resolution logic for zh-TW. Main and renderer i18n modules add lazy-loading support for the zh-TW catalog with a currentOnly load option. Appearance settings expose zh-TW as a selectable, searchable language. A new bootstrap script generates zh-TW.json from zh.json using OpenCC conversion, integrated into locale catalog repair tooling and package scripts. Brand mistranslation data is extracted into its own module, and translation policy repair logic is refactored. All locale catalogs receive new SSH/host removal dialog strings and a zh-TW label, with accompanying tests updated throughout.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Traditional Chinese UI language support.
Description check ✅ Passed All required template sections are present, including screenshots, testing, AI review, security audit, and notes.

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[bot] avatar Jul 08 '26 10:07 coderabbitai[bot]

Hi there, we'd like to support more languages! doing a bit refacotring in our i18n implementation so that we can easily support more.

give us a few days to land this PR

AmethystLiang avatar Jul 12 '26 04:07 AmethystLiang

Thank you for putting this together — and I am sorry it sat unanswered for so long, which is on us, not you.

We are not taking on new UI locales right now. Orca ships en/es/ja/ko/zh, and each one carries ongoing cost beyond the initial catalog: every new English string has to be re-translated, the build-time repair policy needs per-locale glossary and override rules, and mistranslations reach users in surfaces nobody on the team can read. We are currently working through a backlog of correctness bugs in the five we already ship, and adding a sixth before that is under control would not be fair to the people using it.

That is a decision about our capacity, not about the quality of your work. Closing so the queue reflects reality rather than leaving it open indefinitely — if that changes, this is easy to reopen and we will come back to the contributors who offered first.

Thanks again for the time you put in.

nwparker avatar Aug 04 '26 09:08 nwparker

I'm sorry — I closed this, and that was the wrong call. Reopening it.

The reasoning I gave (that we aren't taking on new built-in locales right now) is still true, but closing your PR was not the right way to act on it. You did the work, it sat for months without a reply, and then it got closed with an explanation of our constraints. That's a bad trade for you, and I apologize.

Here's what's actually going on. We do want these locales. What we can't currently take on is maintaining them in-tree, where every new English string becomes translation debt across every catalog and a mistranslation ships to users in a surface nobody on the team can read. So the direction we're working toward is the one where that maintenance sits with the people who actually speak the language: plugin language packs.

Most of that mechanism is already in the repo today:

  • a plugin manifest declares contributes.languagePacks: [{ locale, path }]
  • the pack is a plain catalog JSON with the same key shape as src/renderer/src/i18n/locales/en.json
  • packs are content-integrity verified and approval-gated at install, then registered into i18next at runtime
  • they appear in Settings → Appearance → Language next to the built-in locales
  • Intl formatting — dates, relative times, number formats — resolves through the locale tag the pack declares

The test fixture for that manifest contract uses pt-BR as its worked example, so this isn't hypothetical plumbing.

What's not there yet is the part that would make this pleasant for you: there's no authoring guide, no scaffolding to generate a starter catalog from en.json, no re-sync story when English strings change, and the glossary/repair tooling we use for the built-in locales isn't exposed to pack authors. That's the work in front of us. I'm not going to give you a date I can't keep.

I'd rather leave this open and come back to you when that lands than close it and have you find out from a changelog. If you'd prefer to close it yourself in the meantime, that's entirely your call — but it should be yours, not mine.

Thanks for the work, and sorry again for how I handled it.

nwparker avatar Aug 04 '26 09:08 nwparker

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 src/renderer/src/i18n/locales/zh-Hant.json (glossary in config/i18n-traditional-chinese.md) would be very welcome.

OrcaWin avatar Oct 28 '26 06:10 OrcaWin