Skip to content

feat(cli): add Traditional Chinese (zh-TW) as a UI language option#3569

Merged
wenshao merged 17 commits into
QwenLM:mainfrom
MikeWang0316tw:feat/zh-TW
Apr 24, 2026
Merged

feat(cli): add Traditional Chinese (zh-TW) as a UI language option#3569
wenshao merged 17 commits into
QwenLM:mainfrom
MikeWang0316tw:feat/zh-TW

Conversation

@MikeWang0316tw

Copy link
Copy Markdown
Contributor

Description

Adds Traditional Chinese (zh-TW) as a dedicated UI language option in Qwen Code. Previously, only Simplified Chinese (zh-CN) was available.

This change allows users who prefer Traditional Chinese to select it via /language ui zh-TW or the settings panel.

Changes

  • packages/cli/src/i18n/languages.ts: Added zh-TW language definition (Traditional Chinese / 繁體中文) to SUPPORTED_LANGUAGES and SupportedLanguage type union.
  • packages/cli/src/i18n/locales/zh-TW.js: New file — Traditional Chinese translation based on zh.js (Simplified Chinese), converted using opencc.
  • packages/vscode-ide-companion/schemas/settings.schema.json: Added zh-TW to the language enum and updated the description.
  • scripts/check-i18n.ts: Added zh-TW.js to the i18n key-matching check, so future PRs will verify that zh-TW.js stays in sync with en.js.
  • scripts/unused-keys-only-in-locales.json: Updated by running npm run check-i18n.

How zh-TW.js was generated

The Simplified Chinese locale (zh.js) was converted to Traditional Chinese using opencc (s2t converter). This ensures consistent coverage of all i18n keys while using the correct Traditional Chinese characters.

Testing

  • Built successfully with npm run build
  • Verified with npm run check-i18n — all keys match between en.js and zh-TW.js
  • Manual test: /language ui now shows zh-TW as an option

MikeWang0316tw and others added 2 commits April 24, 2026 00:38
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] npm run check-i18n fails because the new zh-TW locale is not key-synchronized with en.js. Direct key comparison shows 5 missing keys (No server selected, Value:, 中国 (China), 中国 (China) - 阿里云百炼, 阿里云百炼 (aliyun.com)) and 7 extra keys (including the Traditional-character variants of the China/Aliyun labels). Please regenerate or manually sync zh-TW.js so its keys exactly match en.js; only the values should differ.

[Critical] scripts/check-i18n.ts still contains a stale @ts-expect-error for import.meta, and the PR introduces a changed-file typecheck failure because that directive is now unused.

— gpt-5.4 via Qwen Code /review

nativeName: '中文',
},
{
code: 'zh-TW',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] Adding zh-TW after the generic zh entry breaks the new locale for users who keep general.language on auto. detectSystemLanguage() walks SUPPORTED_LANGUAGES in order and uses startsWith(), so zh-TW/zh-TW.UTF-8 matches zh first and still resolves to Simplified Chinese.

Suggested change
code: 'zh-TW',
{
code: 'zh-TW',
id: 'zh-TW',
fullName: 'Traditional Chinese',
nativeName: '繁體中文',
},
{
code: 'zh',
id: 'zh-CN',
fullName: 'Chinese',
nativeName: '中文',
},

— gpt-5.4 via Qwen Code /review

Comment thread scripts/check-i18n.ts
totalKeys,
translatedKeys,
translatedKeys: zhTranslatedKeys,
zhTWTranslatedKeys,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] The returned stats object now includes zhTWTranslatedKeys, but CheckResult.stats was not updated to declare that property. That makes npx tsc --noEmit --incremental fail on this PR.

Suggested change
zhTWTranslatedKeys,
zhTWTranslatedKeys: number;

— gpt-5.4 via Qwen Code /review

MikeWang0316tw and others added 2 commits April 24, 2026 01:48
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] scripts/check-i18n.ts now requires stats.zhTWTranslatedKeys, but some return paths still construct stats without this property, which makes npx tsc --noEmit fail. Either remove this field from the type or populate it in every returned stats object.

[Critical] checkKeyMatching is still hard-coded to emit diagnostics for zh.js; the new zh-TW validation reuses it, so missing or extra keys in zh-TW.js will be reported as zh.js, making the new locale validation misleading. Pass a locale label into the helper and use it in diagnostics.

— gpt-5.5 via Qwen Code /review

Comment thread packages/cli/src/i18n/locales/zh-TW.js Outdated
'全局記憶文件未找到或當前爲空',
'Global memory is currently empty.': '全局記憶當前爲空',
'Global memory content:\n\n---\n{{content}}\n---':
'全局記憶內容:\\n\\n---\\n{{content}}\\n---',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] This value double-escapes newline sequences (\\n), while the source key uses normal newline escapes. When zh-TW is selected, the CLI will render literal \n text instead of line breaks. The same pattern appears in several other translated values in this file.

Suggested change
'全局記憶內容:\\n\\n---\\n{{content}}\\n---',
'全局記憶內容:\n\n---\n{{content}}\n---',

— gpt-5.5 via Qwen Code /review

MikeWang0316tw and others added 4 commits April 24, 2026 03:14
…-i18n.ts

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@MikeWang0316tw MikeWang0316tw requested a review from wenshao April 24, 2026 04:15

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] packages/cli/src/i18n/locales/zh-TW.js 缺少 136 个翻译键(npm run check-i18n 退出码 1)。缺失的键包括 "Status", "Model", "Settings", "Tools", "Yes", "No", "Error", "Back", "cancel", "Hooks", "Extensions", "Workspace" 等基本 UI 文本。使用 zh-TW 语言时这些 UI 字符串将回退显示英文 key 名而非繁体中文。

请使用 opencc (s2t) 从 en.js 或 zh.js 的值补全缺失翻译,然后运行 npm run check-i18n 验证通过。

其余变更(languages.ts、settings.schema.json、check-i18n.ts、useResumeCommand.ts)均正确,构建和测试通过。

— deepseek-v4-pro via Qwen Code /review

MikeWang0316tw and others added 5 commits April 24, 2026 05:32
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Convert zh-TW.js keys from double-quoted to single-quoted to match en.js style
- Fix zh.js key mismatches: add missing keys (Value:, No server selected, prompts, required, Enum) and remove extra keys (The name of the extension to update, Session (temporary))
- Regenerate unused-keys-only-in-locales.json

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Resolve merge conflicts in zh.js (prompts/required translations) and
restore 4 keys that main added to en.js. Regenerate zh-TW.js to sync
all 1267 keys at 100% coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MikeWang0316tw MikeWang0316tw requested a review from wenshao April 24, 2026 07:09
Add getCurrentLanguage() to useMemo deps in usePhraseCycler so that
WITTY_LOADING_PHRASES re-evaluates after a /language switch instead of
staying locked to the language active at mount time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Suggestion] detectSystemLanguage() currently checks environment locales with envLang.startsWith(lang.code). Common POSIX locales use underscores, for example LANG=zh_TW.UTF-8, which does not start with the new zh-TW code and then falls through to the later generic zh entry. Users with a standard zh_TW.UTF-8 environment will still auto-detect Simplified Chinese instead of Traditional Chinese. Consider normalizing separators/case before matching, or comparing normalized code/id values after replacing _ with -.

— gpt-5.5 via Qwen Code /review

nativeName: 'English',
},
{
code: 'zh-TW',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Suggestion] Adding zh-TW as a mixed-case language code exposes an existing case-sensitive lookup in getLanguageNameFromLocale(): normalizeOutputLanguage() lowercases user input before calling it, so /language output zh-TW becomes zh-tw and is preserved as the literal string instead of resolving to Traditional Chinese.

Suggested change
code: 'zh-TW',
code: 'zh-tw',

Alternatively, keep the canonical code and make getLanguageNameFromLocale() compare l.code.toLowerCase() against the normalized input.

— gpt-5.5 via Qwen Code /review

…age lookup

- detectSystemLanguage(): normalize POSIX locales (e.g. zh_TW.UTF-8 → zh-tw)
  by replacing underscores with hyphens and lowercasing before matching, so
  users with LANG=zh_TW.UTF-8 correctly detect zh-TW instead of falling
  through to zh
- getLanguageNameFromLocale(): compare codes case-insensitively so that
  normalizeOutputLanguage('zh-TW') resolves to 'Traditional Chinese' instead
  of falling back to 'English'
- Add test cases for zh-TW / zh-tw / ZH-TW in normalizeOutputLanguage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MikeWang0316tw MikeWang0316tw requested a review from wenshao April 24, 2026 11:36
Add 'zh-tw' entry to the mock map and normalize locale input with
toLowerCase() so the mock mirrors the real case-insensitive implementation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅ — gpt-5.5 via Qwen Code /review

@wenshao wenshao merged commit 12b26ba into QwenLM:main Apr 24, 2026
13 checks passed
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
…wenLM#3569)

* feat(cli): add Traditional Chinese (zh-TW) as a UI language option

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix: use upstream unused-keys-only-in-locales.json to resolve conflict

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* revert: remove check-i18n.ts changes to avoid pre-existing zh.js issues

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* feat(cli): add Traditional Chinese (zh-TW) as a UI language option

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): add WITTY_LOADING_PHRASES to zh-TW locale

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): sync zh-TW.js with en.js keys, fix double-escape, fix check-i18n.ts

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix: resolve conflict in unused-keys-only-in-locales.json

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): add missing Performance translation to zh-TW

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): add quotes to Performance key in zh-TW

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): regenerate zh-TW.js with correct multi-line value parsing

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix: resolve conflict in unused-keys-only-in-locales.json

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): regenerate zh-TW.js with correct multi-line value parsing

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): standardize zh-TW.js key quoting and sync zh.js keys

- Convert zh-TW.js keys from double-quoted to single-quoted to match en.js style
- Fix zh.js key mismatches: add missing keys (Value:, No server selected, prompts, required, Enum) and remove extra keys (The name of the extension to update, Session (temporary))
- Regenerate unused-keys-only-in-locales.json

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): update loading phrases when UI language changes

Add getCurrentLanguage() to useMemo deps in usePhraseCycler so that
WITTY_LOADING_PHRASES re-evaluates after a /language switch instead of
staying locked to the language active at mount time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(i18n): normalize locale separators and fix case-insensitive language lookup

- detectSystemLanguage(): normalize POSIX locales (e.g. zh_TW.UTF-8 → zh-tw)
  by replacing underscores with hyphens and lowercasing before matching, so
  users with LANG=zh_TW.UTF-8 correctly detect zh-TW instead of falling
  through to zh
- getLanguageNameFromLocale(): compare codes case-insensitively so that
  normalizeOutputLanguage('zh-TW') resolves to 'Traditional Chinese' instead
  of falling back to 'English'
- Add test cases for zh-TW / zh-tw / ZH-TW in normalizeOutputLanguage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(test): update getLanguageNameFromLocale mock to include zh-TW

Add 'zh-tw' entry to the mock map and normalize locale input with
toLowerCase() so the mock mirrors the real case-insensitive implementation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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