Skip to content

feat(i18n): add Traditional and Simplified Chinese UI localization - #667

Open
hot-YUser wants to merge 1 commit into
ntdevlabs:winui-previewfrom
hot-YUser:feat/localization-zh-hant-zh-hans
Open

hot-YUser wants to merge 1 commit into
ntdevlabs:winui-previewfrom
hot-YUser:feat/localization-zh-hant-zh-hans

Conversation

@hot-YUser

Copy link
Copy Markdown

Summary

Add resource-based UI localization to the WinUI app and ship Traditional Chinese (zh-Hant) and Simplified Chinese (zh-Hans) alongside English.

  • All interactive UI text now comes from Strings/<tag>/Resources.resw through a small Loc/{loc:Tr Key=…} seam. English remains the source language.
  • Translate the main window, removal catalog, build/settings/review pages, notices, confirmation dialogs and the full cancel flow.
  • Add a Language picker in the sidebar. The choice is stored in %LOCALAPPDATA%\Tiny11Builder\settings.json and applied after a restart; the notice offers Restart now.
  • Add docs/translations.md describing the file layout, key rules and how to add another language.
  • Add LocalizationTests: key parity across languages, non-empty values, matching {0} placeholders, XAML key coverage, and tag normalization (zh-TW → zh-Hant, zh-CN → zh-Hans).

Technical build-engine operation names, stage status words, the raw recipe and the build log remain English diagnostics; the interactive interface, removal catalog and user-facing notices are localized.

Why

Related to #651, #652 and #656. The app previously had no resource files at all: every string was hard-coded in XAML or C#.

Implementation notes

  • The app is unpackaged, so MRT Core needs the PRI file at the default path. ProjectPriFileName is set to resources.pri; without it ResourceLoader does not find the app resources.
  • ApplicationLanguages.PrimaryLanguageOverride is set before any XAML is parsed, so markup-extension text resolves in the selected language.
  • Keys are flat with __ separators. MRT treats dots as resource-map separators, so a dotted key such as A.B cannot also be a parent of A.B.C.
  • Adding a language is one copied Resources.resw file plus one LanguageCatalog entry; the tests enforce parity.

Verification

  • dotnet build src/Tiny11Builder.App/Tiny11Builder.App.csproj -c Release: 0 warnings, 0 errors.
  • Localization/app tests: 85 passed (LocalizationTests, AppFlowTests, AppChoiceTests, ProjectSupportTests, DeploymentTests).
  • Full suite: 529 passed, 35 failed. The same 35 tests fail on a clean checkout of 8909da1 in this non-elevated environment (SeBackupPrivilege/DISM native tests); the three new localization tests are included in the 529 and no new failures were introduced.
  • Manually verified both Chinese UIs render correctly, the language picker lists System default / English / 繁體中文 / 简体中文, selecting 简体中文 writes settings.json, and Restart now relaunches into the new language.

摘要(繁體中文)

為 WinUI 應用程式加入以資源檔為基礎的介面在地化,並隨附英文、繁體中文(zh-Hant)與簡體中文(zh-Hans)。

  • 介面文字集中於 Strings/<tag>/Resources.resw,透過 Loc 與 {loc:Tr Key=…} 解析;英文為來源語言。
  • 翻譯主視窗、移除目錄、建置/設定/檢閱頁面、通知、確認對話框與完整取消流程。
  • 側邊欄新增語言選擇器;選擇會寫入 %LOCALAPPDATA%\Tiny11Builder\settings.json,重新啟動後套用,通知列提供「立即重新啟動」。
  • 新增 docs/translations.md 說明資源結構與新增語言流程。
  • 新增 LocalizationTests:語言鍵一致性、非空值、{0} 佔位符一致、XAML 鍵覆蓋,以及語系標籤正規化。

建置引擎的操作名稱、階段狀態字、原始配方與建置記錄仍為英文技術診斷;互動介面、移除目錄與使用者可見通知均已翻譯。

驗證:Release 建置 0 警告 0 錯誤;相關測試 85 項全數通過;完整測試的 35 項失敗與未修改前的基準完全相同(此非提權環境缺少 SeBackupPrivilege/DISM),未新增失敗。實機確認兩種中文介面、語言選擇寫入設定,以及重新啟動後套用新語言。

- 以 resw 資源檔與 Tr 標記延伸集中管理介面文字,English 為來源語言
- 新增語言選擇、settings.json 持久化與重新啟動套用
- 翻譯主視窗、移除目錄、通知、對話框與取消流程
- 新增資源鍵、佔位符與語言對應測試,以及翻譯文件
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