Skip to content

Add Simplified Chinese localization (#113)#130

Open
tsouth89 wants to merge 1 commit into
mainfrom
feat/chinese-localization
Open

Add Simplified Chinese localization (#113)#130
tsouth89 wants to merge 1 commit into
mainfrom
feat/chinese-localization

Conversation

@tsouth89

@tsouth89 tsouth89 commented Jul 23, 2026

Copy link
Copy Markdown
Owner

@
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 by format_template and the leading-space status overlays (e.g. (错误)) are preserved verbatim (verified: 0 format-token mismatches vs en-US).
  • rust/src/locale.rslanguage_id() no longer hardcodes en-US; Language::Chinesezh-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 existing LocaleProvider (no restart).
  • Tests — Rust coverage for the Chinese bundle, placeholder preservation, and the English fallback; frontend test for the switcher.

Gates

  • cargo test --workspace ✅ · cargo fmt --all --check ✅ · cargo clippy --all-targets -D warnings
  • pnpm check-locale (640 keys match) ✅ · tsc --noEmit ✅ · vitest run 300 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

    • Added Simplified Chinese as an interface language option.
    • Added language selection to General settings.
    • Expanded Chinese translations across settings, notifications, usage, providers, shortcuts, and other interface areas.
    • Added fallback to English when a translation is unavailable.
  • Bug Fixes

    • Improved locale formatting for dynamic values, statuses, and notifications.

@
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
@
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Simplified Chinese localization, maps Chinese language selection to zh-CN, and introduces a General settings language selector with frontend and Rust test coverage.

Changes

Chinese localization support

Layer / File(s) Summary
Chinese locale resolution and translations
rust/src/locale.rs, rust/src/locale/tests.rs, rust/src/locale/zh-CN.ftl
Chinese selection resolves to zh-CN; the new Fluent bundle provides translated UI strings, formatting placeholders, and English fallback coverage.
Settings language picker
apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx, apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.test.tsx
General settings renders typed language options, calls setLanguage on selection, and verifies the Chinese option interaction.

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
Loading

Possibly related PRs

  • tsouth89/ceiling#40: Adds locale keys and UI text that depend on the Chinese language plumbing and translation bundle.
  • tsouth89/ceiling#41: Modifies the same locale resolution and translation files with conflicting non-English locale behavior.

Suggested reviewers: finesssee

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Simplified Chinese localization.
Linked Issues check ✅ Passed The PR satisfies #113 by adding zh-CN translations, a Settings language switcher, and live language switching with fallback coverage.
Out of Scope Changes check ✅ Passed The changes stay focused on Chinese localization and related tests, with no明显 unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chinese-localization

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
rust/src/locale/tests.rs (1)

20-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a completeness check for the Chinese bundle.

These tests cover only a few keys and raw placeholder strings. Since get_text intentionally falls back to English, missing or malformed entries among the remaining keys could pass while violating the full-translation objective. Compare the LocaleKey inventory and placeholder sets against zh-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

📥 Commits

Reviewing files that changed from the base of the PR and between 2041ea0 and 3b59896.

📒 Files selected for processing (5)
  • apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx
  • rust/src/locale.rs
  • rust/src/locale/tests.rs
  • rust/src/locale/zh-CN.ftl

Comment on lines +84 to +86
<Select
value={settings.uiLanguage}
options={LANGUAGE_OPTIONS}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Suggested change
<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.

Comment thread rust/src/locale/zh-CN.ftl
TabAbout = 关于
TabShortcuts = 快捷键
InterfaceLanguage = 界面语言
StartupSettings = 系统

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Suggested change
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.

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.

[Feature]: Add Chinese localization / Chinese language support

1 participant