Add i18n internationalization support#4032
Add i18n internationalization support#4032guixiao2026 wants to merge 4 commits intoChrisTitusTech:mainfrom
Conversation
|
This approach works well, but with each language we add to winutil via this PR, the winutil.ps1 file increases by about 100 KB. Adding 12 more languages would bring it close to 2 MB. |
what if during build, every language gets its own .ps1 build, tagged with the built language? one step further: when running the stable branch, it could check for the current user locale, and download the corresponding ps1 file. |
ye im pretty sure thats what chris wants |
|
Let me think about it. |
- Remove en.json (English strings already hardcoded as defaults) - Strip app descriptions from zh-TW.json (~55KB -> ~13KB) - Embed only manifest.json at compile time, not full locale files - Add Get-WinUtilLocale with 3-tier resolution: memory/cache/download - Add download icon for uncached languages in language menu - Create locale cache directory on startup
Summary
Add a JSON-based internationalization (i18n) system to WinUtil, allowing the UI to be translated into any language by simply adding a locale JSON file.
What changed
Compile.ps1locales/from preprocessing; embed locale JSON with explicit UTF-8 reading; output compiled script with UTF-8 BOM to preserve non-ASCII charactersfunctions/private/Set-WinUtilLanguage.ps1Set-WinUtilLanguage(config overlay with English fallback),Set-WinUtilLanguageUI(XAML element updates),Get-WinUtilAvailableLanguages(locale discovery)locales/en.jsonlocales/zh-TW.jsonscripts/main.ps1xaml/inputXML.xamlHow it works
locales/*.jsonare embedded during compilationHow to add a new language
locales/en.jsontolocales/{locale-code}.json(e.g.,ja.json)_metadata.namewith the display name (e.g., "日本語")ui,categories, and description fields.\Compile.ps1— the new language appears automatically in the menuDesign decisions
[System.IO.File]::ReadAllText()with UTF-8 encoding avoids corruption on non-English Windows systems where default encoding may be ANSI/Big5Test plan
.\Compile.ps1and verify syntax validation passeswinutil.ps1is not included in the commit