Skip to content

feat(settings): add i18n support and translate settings UI to zh-CN#517

Open
huahai0202 wants to merge 4 commits intoDimillian:mainfrom
huahai0202:feat/settings-i18n-zh-cn
Open

feat(settings): add i18n support and translate settings UI to zh-CN#517
huahai0202 wants to merge 4 commits intoDimillian:mainfrom
huahai0202:feat/settings-i18n-zh-cn

Conversation

@huahai0202
Copy link

@huahai0202 huahai0202 commented Feb 26, 2026

Overview

  • Introduce a lightweight frontend i18n infrastructure (Provider / useI18n / dictionaries / language resolution / key alignment tests)
  • Add and persist uiLanguage (system | en | zh-CN), with backward compatibility between frontend and backend configs
  • All Settings page text migrated to dictionaries and aligned with the latest upstream SettingsPrimitives refactor structure

Changes

  • Added src/i18n/*:

    • index.ts / provider.tsx / useI18n.ts / types.ts
    • locales/en.ts / locales/zh-CN.ts
    • index.test.ts
  • Integrated I18nProvider in src/App.tsx

  • Added uiLanguage to both frontend and Rust settings models, including default value and normalization compatibility

  • SettingsFeaturesSection priority fixed: backend displayName/description/announcement now overrides local fallback

  • Added hasKey to support safe fallback for dynamic keys (prevents showing raw keys when missing)


Verification

  • npm run typecheck
  • npm run test -- src/i18n/index.test.ts src/features/settings/components

Notes

  • This PR focuses on Settings page localization and i18n infrastructure
  • Main UI (chat area / sidebar / toast, etc.) is out of scope for this PR

@huahai0202
Copy link
Author

image

@huahai0202 huahai0202 force-pushed the feat/settings-i18n-zh-cn branch from 22cee3a to 5dc8ca6 Compare February 26, 2026 09:37
@Dimillian
Copy link
Owner

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@huahai0202 huahai0202 force-pushed the feat/settings-i18n-zh-cn branch from c5e1d13 to aafdec8 Compare February 27, 2026 12:06
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aafdec89d9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 139 to 143
if (zh) {
const translatedFallback = FEATURE_DESCRIPTION_FALLBACKS_ZH[feature.name];
if (translatedFallback) {
return translatedFallback;
}

Choose a reason for hiding this comment

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

P2 Badge Use backend feature copy before zh fallback descriptions

In featureSubtitle, the new zh-CN branch returns FEATURE_DESCRIPTION_FALLBACKS_ZH before checking feature.description/feature.announcement, so zh users no longer see server-provided feature messaging for known flags. This regresses behavior from the previous implementation and can hide updated rollout/deprecation details that Codex sends dynamically; the localized fallback should only apply when backend description fields are empty.

Useful? React with 👍 / 👎.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6a05720a5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 117 to 121
if (zh) {
const translatedLabel = FEATURE_LABELS_ZH[feature.name];
if (translatedLabel) {
return translatedLabel;
}

Choose a reason for hiding this comment

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

P2 Badge Prefer backend display names before zh label fallbacks

In zh-CN, formatFeatureLabel returns the hardcoded FEATURE_LABELS_ZH entry before checking feature.displayName, so known flags no longer surface server-provided names. This is a regression from prior behavior and can hide backend renames or rollout messaging for those flags; the localized label should be used only when displayName is absent.

Useful? React with 👍 / 👎.

@Dimillian
Copy link
Owner

FYI, thanks a lot for this, but I'm not sure I want to have and support localization in this app. As a maintainer of a lot of other open source projects I know this bring a lot of work for me and associated localization maintainers.

@huahai0202
Copy link
Author

Thanks for the feedback — totally understood. I know localization adds long-term maintenance cost. I’m happy to close this PR if you prefer. Really appreciate your review and your work maintaining the project.

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.

2 participants