WeKnora/frontend/public
Junhao Ye d2bc0df6a2
feat(i18n): add Traditional Chinese (zh-TW) locale support (#3916)
* i18n(zh-TW): add Traditional Chinese (Taiwan) locale bundle (6,547 keys)

機械產生自 zh-CN.ts:以 zhconv (zh-tw) 為字形基底,詞彙層以 tw-terms.tsv(364 條生效詞條)覆寫,保留 26 條 never 與 47 條保護詞。骨架等價、鍵序列、Node 真實載入、內嵌區塊 四道檢查皆通過(詳見審計目錄)。

* i18n(zh-TW): register locale bundle in i18n infrastructure (5 → 6)

- resolveDefaultLocale.ts: SUPPORTED_LOCALES = ['zh-CN','zh-TW','en-US','ru-RU','ko-KR','ja-JP']
- i18n/index.ts: 載入 zhTW 並掛入 messages['zh-TW']
- localeKeyAudit.ts: 加入 LOCALE_BUNDLES['zh-TW'] 與測試守門(LOCALE_ORDER、emptyBundles)
- localeKeyAudit.test.ts: 把 zh-TW 補進期望清單
- locales/{en-US,ja-JP,ko-KR,ru-RU,zh-CN}.ts: language 區塊補 zhTW 顯示名(讓語言切換器正確顯示繁中選項)

* i18n(zh-TW): fix normalizeEmbedLocale and add zh-TW embed block (514 keys)

原實作 startsWith('zh') 直接命中 zh-TW/zh-HK/zh-Hant 並回傳 zh-CN
→ 繁中使用者將永遠看到簡體字串。修正後:
  - 繁中變體 (zh-tw/zh-hk/zh-mo/zh-hant) 排在通用 zh 之前,優先回傳 zh-TW
  - 內嵌 zh-TW 區塊加入 514 個字串,骨架與 zh-CN 區塊逐字元相同(只換區塊名)

* i18n(zh-TW): wire zh-TW into UI language pickers and TDesign locale

- App.vue: 載入 tdesign-vue-next esm/zh_TW,tdLocaleMap['zh-TW'] = zhTWConfig
- Login.vue: 語言切換器新增 { value: 'zh-TW', label: '繁體中文', shortLabel: '繁中', flag: '繁' }
  (刻意不用旗標 emoji,改以「繁」字標示,語意清楚且無爭議)
- GeneralSettings.vue: 設定頁語言下拉新增 <t-option value='zh-TW' ...>
- AgentEmbedChannelPanel.vue: 代理嵌入頻道語言選單新增繁中
- IMChannelPanel.vue: IM 頻道語言選單新增繁中

* i18n(zh-TW): widen API union types and update tests for zh-TW

- api/agent/index.ts: IMChannel.locale 聯合型別補 'zh-TW'
- api/embed/index.ts: EmbedLocaleTag 聯合型別補 'zh-TW'
- i18n/embedLocale.test.ts: supported-list 期望補上 zh-TW;新增 7 條 normalizeEmbedLocale 斷言(覆蓋 zh-tw / zh-hk / zh-mo / zh-hant / zh-Hant-TW 等變體正確路由到 zh-TW)
- locales/workspaceTerminology.test.ts: workspace 詞彙測試也對 zh-TW 做同樣的禁用詞斷言(與其他 locale 同步)

* i18n(zh-TW): add zh-TW to backend supportedLocales whitelist

- internal/types/locale.go: supportedLocales["zh-TW"] = {}
  (NormalizeSupportedLocale 會靜默丟掉未列出的 tag,導致前端語言選擇器實際寫入空字串——
   此修正保證前端選 zh-TW 時 embed 預設語言與 IM 回覆語言會被後端接受)
- internal/types/locale_test.go: 期望清單補上 zh-TW
- internal/handler/mcp_usage_instructions.go: MCP 工具使用說明對照表新增 zh-TW → 'Traditional Chinese'

* fix(i18n): translate revoke as 撤銷 in zh-TW and allow zh-TW as the runtime default locale

The zh-CN → zh-TW conversion turned every 撤销 into 復原 (restore), so
revoke buttons for OAuth tokens, device pairing, invitations and system
admins read as the opposite action. Only the undo sense (此操作不可撤销)
keeps 復原.

docker-entrypoint.sh whitelists DEFAULT_LOCALE and did not accept zh-TW,
so DEFAULT_LOCALE=zh-TW silently fell back to Simplified Chinese. Also
list zh-TW in the IM locale error and the locale hints.

---------

Co-authored-by: junhao-ye <junhao-ye@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-10-08 16:18:17 +08:00
..
tdesign-icons/0.4.1/fonts fix(frontend): bundle tdesign-icons sprite locally for offline deploys 2026-04-23 18:21:49 +08:00
config.js feat(i18n): add Traditional Chinese (zh-TW) locale support (#3916) 2026-10-08 16:18:17 +08:00
favicon.ico init commit 2025-08-05 15:08:07 +08:00
weknora-widget.js feat(i18n): add Traditional Chinese (zh-TW) locale support (#3916) 2026-10-08 16:18:17 +08:00