Skip to content

feat(i18n): add typed i18n scaffolding, language picker, and zh-CN Settings - #57

Draft
BubuWang-996 wants to merge 1 commit into
splashxmoon:mainfrom
BubuWang-996:feat/i18n-scaffolding-settings
Draft

BubuWang-996 wants to merge 1 commit into
splashxmoon:mainfrom
BubuWang-996:feat/i18n-scaffolding-settings

Conversation

@BubuWang-996

Copy link
Copy Markdown

Opening an early draft PR as suggested so you can take a look at the shape before I move on to the remaining areas (sidebar, new thread, session view, Crew, etc.).

Approach (Option A)

  • Zero new dependencies: lightweight typed t(key, "English fallback", vars?) in src/client/i18n/index.ts, with canonical keys in src/client/i18n/keys.ts.
  • English stays inline as source & fallback: untranslated strings automatically fall back to the inline English text, and adding a new English key does not require translating it first (zh-CN.ts is typed as Partial<Record<MessageKey, string>>).
  • Lazy-loaded zh-CN catalog: src/client/i18n/zh-CN.ts is only loaded when zh-CN is active, so English users pay zero extra first-load bundle bytes (test/client-bundle.test.ts stays well under budget).
  • Standard Intl formatting: plurals (Intl.PluralRules), numbers (Intl.NumberFormat), dates (Intl.DateTimeFormat), and relative times (Intl.RelativeTimeFormat) go through Intl helpers while preserving regional formats (e.g. en-GB) when following the system locale.

Scope in this PR

  1. i18n scaffolding (src/client/i18n/):
    • System language detection (zh, zh-CN, zh-Hans, zh-SG → zh-CN; everything else falls back to en), plus storage / languagechange sync across tabs and in-memory fallback when storage is blocked.
    • Reactive useLocale() / useT() hooks via useSyncExternalStore so switching language updates the UI immediately without a reload.
    • Persisted under mpa.locale in src/client/prefs.ts (included in Settings export/import/reset; system clears the override).
  2. Language picker in Settings › Appearance:
    • Scrollable Select dropdown (System with detected language hint / English / 简体中文).
  3. Settings & Usage translated to zh-CN:
    • Navigation groups, section titles/blurbs, bilingual Settings search (both Chinese and English queries work), Appearance, Backdrop, Notifications, Voice, Shortcuts, Coding tools (tool rows, auto-update, Editor, Proof clips), Models, Project memory, Permissions, Usage (limits, accounts, activity), This computer, Other computers & Hosts, GitHub, Privacy, Storage, Backup & reset, Updates (AppUpdate, Health, Diagnostics), and Help & feedback.
  4. Tests:
    • Added test/i18n.test.ts covering system locale detection, English fallback, lazy zh-CN loading & failure recovery, Intl helpers & regional format preservation, blocked storage fallback, cross-tab sync, and bilingual Settings search.

Verification

  • npm run typecheck passes with 0 errors.
  • test/i18n.test.ts, test/settings-search.test.ts, test/client-bundle.test.ts, test/health.test.ts, and test/palette.test.ts pass (31/31).

Happy to tweak the naming, file structure, or key conventions before continuing with the next PR.

P.S. Just wanted to say I really love your taste and aesthetic — the UI feels super crisp, cohesive, and thoughtfully crafted!

@BubuWang-996
BubuWang-996 force-pushed the feat/i18n-scaffolding-settings branch from e73a3d1 to aa3d22f Compare December 2, 2026 12:19
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.

1 participant