Add Simplified Chinese localization (#113)#130
Conversation
Add Simplified Chinese localization (#113) Ceiling shipped English-only after the CodexBar fork, but the locale scaffolding (Language enum, Fluent loader, LocaleProvider, catalog) was left intact. Re-connect it for Simplified Chinese: - Add rust/src/locale/zh-CN.ftl translating all 640 keys, preserving the {}/{:.0} format tokens and leading-space status overlays verbatim. - Un-hardcode language_id() so Language::Chinese resolves to the zh-CN bundle. Other languages fall back to English via Fluent, so any future key missing a translation still renders readable English (no CI gate on translation completeness). - Restore the Interface Language selector in the General settings tab, offering only the languages we ship a bundle for (English, 中文). - Add Rust tests for the Chinese bundle, placeholder preservation, and the English fallback. Closes #113 @
📝 WalkthroughWalkthroughAdds Simplified Chinese localization, maps Chinese language selection to ChangesChinese localization support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant GeneralTab
participant LocaleProvider
participant RustLocale
participant zhCNBundle
User->>GeneralTab: Select "中文"
GeneralTab->>LocaleProvider: setLanguage("chinese")
LocaleProvider->>RustLocale: Resolve selected language
RustLocale->>zhCNBundle: Load zh-CN messages
zhCNBundle-->>GeneralTab: Return translated interface text
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ceiling | 3b59896 | Commit Preview URL Branch Preview URL |
Jul 23 2026, 03:54 AM |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
rust/src/locale/tests.rs (1)
20-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a completeness check for the Chinese bundle.
These tests cover only a few keys and raw placeholder strings. Since
get_textintentionally falls back to English, missing or malformed entries among the remaining keys could pass while violating the full-translation objective. Compare theLocaleKeyinventory and placeholder sets againstzh-CN.ftl, and exercise formatting for representative arguments.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/src/locale/tests.rs` around lines 20 - 60, The locale tests should validate the complete LocaleKey inventory against zh-CN.ftl rather than only checking selected Chinese strings. Add a completeness test around get_text that verifies every key has a Chinese translation, compares placeholder sets with the English entries, and formats representative arguments to confirm placeholders remain usable; keep the existing fallback test for languages without a bundle.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx`:
- Around line 84-86: Normalize settings.uiLanguage before passing it to the
Select in GeneralTab: preserve "chinese" and use "english" for all unsupported
persisted values, matching LANGUAGE_OPTIONS. Keep the existing options and other
selector behavior unchanged.
In `@rust/src/locale/zh-CN.ftl`:
- Line 12: Update the StartupSettings localization entry to use native Chinese
wording meaning “Startup Settings,” such as “启动设置,” instead of the generic “系统”
label.
---
Nitpick comments:
In `@rust/src/locale/tests.rs`:
- Around line 20-60: The locale tests should validate the complete LocaleKey
inventory against zh-CN.ftl rather than only checking selected Chinese strings.
Add a completeness test around get_text that verifies every key has a Chinese
translation, compares placeholder sets with the English entries, and formats
representative arguments to confirm placeholders remain usable; keep the
existing fallback test for languages without a bundle.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5b89bb38-1854-4ce0-8073-66c22267e0c5
📒 Files selected for processing (5)
apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.test.tsxapps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsxrust/src/locale.rsrust/src/locale/tests.rsrust/src/locale/zh-CN.ftl
| <Select | ||
| value={settings.uiLanguage} | ||
| options={LANGUAGE_OPTIONS} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Normalize unsupported persisted language values before rendering.
LANGUAGE_OPTIONS contains only "english" and "chinese", while rust/src/settings/types.rs still accepts other language values. rust/src/locale.rs renders those values as English, but value={settings.uiLanguage} has no matching option, so the selector cannot represent the active language for existing users. Fall back to "english" (or migrate the stored value) before passing it to Select.
Proposed fix
- value={settings.uiLanguage}
+ value={
+ LANGUAGE_OPTIONS.some(({ value }) => value === settings.uiLanguage)
+ ? settings.uiLanguage
+ : "english"
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <Select | |
| value={settings.uiLanguage} | |
| options={LANGUAGE_OPTIONS} | |
| value={ | |
| LANGUAGE_OPTIONS.some(({ value }) => value === settings.uiLanguage) | |
| ? settings.uiLanguage | |
| : "english" | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx` around lines 84
- 86, Normalize settings.uiLanguage before passing it to the Select in
GeneralTab: preserve "chinese" and use "english" for all unsupported persisted
values, matching LANGUAGE_OPTIONS. Keep the existing options and other selector
behavior unchanged.
| TabAbout = 关于 | ||
| TabShortcuts = 快捷键 | ||
| InterfaceLanguage = 界面语言 | ||
| StartupSettings = 系统 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use startup-specific Chinese wording.
Line [12] is the heading for the start-at-login and start-minimized controls, but 系统 means “System” and loses the “Startup” meaning. Use 启动设置 or equivalent native wording.
Proposed fix
-StartupSettings = 系统
+StartupSettings = 启动设置📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| StartupSettings = 系统 | |
| StartupSettings = 启动设置 |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rust/src/locale/zh-CN.ftl` at line 12, Update the StartupSettings
localization entry to use native Chinese wording meaning “Startup Settings,”
such as “启动设置,” instead of the generic “系统” label.
@
Closes #113.
What
Adds Simplified Chinese as a real, switchable UI language. English-only was a naive call after the CodexBar fork; a user asked for Chinese (#113), and the locale scaffolding was still intact, so this re-connects it.
Approach (best-effort, English fallback)
Rather than gating CI on translation completeness for every language, missing keys fall back to English via Fluent. So new strings keep shipping in English and get translated when someone gets to them — no permanent per-string tax, no rotting placeholders showing raw keys.
Changes
rust/src/locale/zh-CN.ftl— translates all 640 keys. The{}/{:.0}format tokens consumed byformat_templateand the leading-space status overlays (e.g.(错误)) are preserved verbatim (verified: 0 format-token mismatches vs en-US).rust/src/locale.rs—language_id()no longer hardcodes en-US;Language::Chinese→zh-CN, everything else falls back to English.GeneralTab.tsx— restores the Interface Language selector, offering only languages we ship a bundle for (English, 中文). Switching is live via the existingLocaleProvider(no restart).Gates
cargo test --workspace✅ ·cargo fmt --all --check✅ ·cargo clippy --all-targets -D warnings✅pnpm check-locale(640 keys match) ✅ ·tsc --noEmit✅ ·vitest run300 passed ✅Note on translation quality
The Chinese is AI-generated with a consistent glossary and placeholder constraints. It should be reviewed by a native speaker before release — corrections welcome.
@
Summary by CodeRabbit
New Features
Bug Fixes