fix(i18n): show English Memory settings labels instead of Chinese fallback#246
Open
craigamcw wants to merge 1 commit into
Open
fix(i18n): show English Memory settings labels instead of Chinese fallback#246craigamcw wants to merge 1 commit into
craigamcw wants to merge 1 commit into
Conversation
…lish UI
SettingsMemory.tsx referenced ~37 memory.* i18n keys that were never added
to the locale files and passed Chinese strings as the t() default value.
With those keys missing from en.json, English users got the Chinese
fallbacks (e.g. "运行时配置", "默认继承当前激活的 API 配置…").
- Add the missing memory.* keys to en.json (English) and zh.json (the
strings previously hardcoded as defaults), keeping both locale key sets
in sync as the i18n README requires.
- Drop the inline Chinese t() default arguments so the source matches the
project convention of t('key') only.
- Remove the now-dead Chinese fallbacks in SettingsPanel.tsx (those keys
already existed in en.json, so English was already correct there).
- Localize the default config-set names ("默认方案" / "配置方案 N") in
useApiConfigState via the i18n instance + new api.* keys.
typecheck, eslint, prettier and the renderer/config vitest suite all pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Review mode: initial
Findings
- [Minor] Potential i18n initialization timing risk in
useApiConfigState.ts:434. The exported functionbuildApiConfigSetsusesi18n.t()directly via module-level import. Although currently called only from within React component lifecycle (reducer initializer), if called before i18n is initialized (e.g., during module evaluation in tests or future refactors), it could throw or return a missing-key fallback. Consider passing thetfunction as a parameter to make the dependency explicit and safe for any caller.// Suggested approach: accept t as parameter export function buildApiConfigSets( options: BuildApiConfigSetsOptions, t: (key: string, options?: Record<string, unknown>) => string // pass t from useTranslation hook or i18n.t ): ApiConfigSet[] { ... }
Summary
No blockers or regressions. The change correctly moves hardcoded Chinese default strings into en.json and zh.json, eliminating the i18n anti-pattern where the Chinese string was used as the fallback for all languages. All keys referenced in the changed source files (SettingsMemory.tsx, SettingsPanel.tsx, useApiConfigState.ts) have been verified to exist in both locale files. The diff is clean and well-scoped. The risk described above is minor and exists only under hypothetical non-React usage; the current code works correctly.
Testing
Not run (automation). The PR states 89 tests pass. No new tests were added for the i18n key coverage, which is acceptable for a pure i18n refactor.
Open Cowork Bot
craigamcw
added a commit
to craigamcw/open-cowork
that referenced
this pull request
Jun 16, 2026
- Fix the active-language highlight in SettingsGeneral: the old
`startsWith('zh') ? 'zh' : 'en'` logic never matched the new languages.
Normalize to the base code (es-ES -> es, zh-CN -> zh) and map Norwegian
nb/nn -> the shipped `no` locale.
- Add nb/nn -> no fallback and `nonExplicitSupportedLngs` so browser region
variants (e.g. es-ES, de-DE, nb-NO) resolve to the right locale.
- Restore the original Chinese comments in i18n/config.ts (only functional
changes remain in the diff).
- Add memory.* and api.* keys to en.json/zh.json so all 12 locales share an
identical key set (these mirror OpenCoworkAI#246).
- Add a Vitest key-parity test (src/tests/i18n/) asserting every locale has
exactly the same keys as en.json, to catch future drift.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cursor Bot
pushed a commit
to Emilien-Etadam/open-cowork
that referenced
this pull request
Jun 23, 2026
Adds full UI translations for Spanish (es), French (fr), German (de), Italian (it), Ukrainian (uk), Polish (pl), Swedish (sv), Norwegian (no), Dutch (nl) and Romanian (ro), alongside the existing English and Chinese. - New locale files under src/renderer/i18n/locales/ (all 866 keys, native orthography, interpolation placeholders preserved) - Register the locales and extend supportedLngs in i18n/config.ts - Add the languages to the Settings -> General language switcher The browser/UI language detector already picks these up automatically. Complements the Memory-settings English-fallback fix in OpenCoworkAI#246 (the new locales include those keys). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the app language resolves to English, several Memory settings labels still render in Chinese — e.g.
运行时配置and默认继承当前激活的 API 配置。这里主要调节导航深度、embedding 和落盘目录。.Root cause:
SettingsMemory.tsxcallst('memory.xxx', '<Chinese>')for ~37 keys, passing the Chinese string as i18next's default value (2nd arg). Thosememory.*keys were never added toen.json(orzh.json), so i18next falls back to the inline Chinese for every language. The keys exist nowhere, so evenzhwas relying on the inline defaults.This is the i18n anti-pattern the project's own
src/renderer/i18n/README.mdwarns against ("避免硬编码 — 所有用户可见的文本都应该通过t()函数").Fix
memory.*keys toen.json(proper English) andzh.json(the strings that were previously hardcoded as defaults). The two locale key sets stay in sync, as the i18n README requires.t()default arguments inSettingsMemory.tsxso the source usest('key')only, matching the rest of the codebase. This also removes the latent trap where any future missing key silently reintroduces Chinese.SettingsPanel.tsx(settings.remote/settings.remoteDescalready existed inen.json, so English was already correct there — the inline Chinese was just redundant).默认方案/配置方案 N) inuseApiConfigState.tsvia the i18n instance + two newapi.*keys, so a fresh English install no longer shows a Chinese profile name.Intentionally not touched: the
中文native-language label inSettingsGeneral.tsx(correct as-is) and Chinese code comments (not user-visible).Verification
tsc --noEmit— passeseslint srcon the changed files — 0 errors (2 pre-existing unrelated warnings)prettier --check— cleanen.jsonandzh.json; thememoryandapinamespace key sets match between locales.No behavior change for Chinese users (same strings, now sourced from
zh.json); English users now get English.