Skip to content

fix(windows): localize WinSparkle dialogs - #300

Merged
houko merged 3 commits into
mainfrom
fix/windows-update-language
Nov 16, 2026
Merged

houko merged 3 commits into
mainfrom
fix/windows-update-language

Conversation

@houko

@houko houko commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #299.

WinSparkle was started before the mounted app's locale and catalog match were known, and NSGo never called win_sparkle_set_lang, so its dialogs always followed the Windows UI language. Now:

  • core.Tree.Language and engine.Engine.Language return the language the app shows (core.Env.Language). Engine.Language waits for what is already queued on the engine, the app's mount included, so a locale the app sets while it mounts counts; it returns "" once the engine has ended.
  • The Windows backend asks for it only once WinSparkle is about to start (a feed is configured and WinSparkle.dll loaded), so an app without updates never holds its message loop for the mount, and passes updates.WinSparkleLanguage's name to win_sparkle_set_lang before win_sparkle_init.
  • updates.WinSparkleLanguage maps a catalog language to a translation WinSparkle 0.9.4 ships (its translations/ directory). Names are lower case (zh_cn, not zh_CN): wxWidgets lists the translations in WinSparkle.dll by their lowered resource names and compares the language set case-sensitively, so a regional name in the file's own case finds nothing and shows English. zh-Hans/zh map to zh_cn and zh-Hant/zh-TW/zh-HK to zh_tw (by script, inferred when the tag leaves it out), pt and pt-BR to pt_br, pt-PT to pt_pt, sr-Latn to sr@latin, no to nb, ca/fy/gl to their regional files, and other shipped languages by their base (de-CH to de).
  • English maps to en, WinSparkle's own language, so an English app on a non-English Windows shows English dialogs, the reverse case the issue describes. An app without catalogs, or whose language WinSparkle does not translate, sets nothing and keeps WinSparkle's default, the Windows UI language; setting an untranslated language would make wxWidgets show English instead.
  • WinSparkle takes the language only before it starts, so a language the app switches to later shows from the next launch. docs/architecture/updates.md says so and records the Windows run; the public building docs (en, zh) say the Windows updater uses the app's language.

Verification

  • go build ./...; vets for windows/amd64, linux/amd64, android/arm64 and js/wasm of the touched packages; windows/386 and windows/arm64 builds of internal/platform/windows; go tool nsgo check -target all.
  • go tool nsgo test on ./internal/platform/updates, ./internal/engine, ./core, ./cmd/nsgo, and -run 'Layer|Skills|Doc' ..
  • TestWinSparkleLanguage covers the mapping, its lower case, English and unsupported languages. TestLanguageReadsTheMountedApp asks before the first commit arrives, so it needs Language to wait for the mount, and checks that it returns after Close.
  • Windows 11 x64 with an en-US UI: I ran a probe app that ships en, zh-Hans, zh-Hant, pt-BR and ja catalogs, forces a locale and checks for updates as it starts, with WinSparkle 0.9.4 beside it. WinSparkle's dialog came up in Simplified Chinese, Traditional Chinese, Brazilian Portuguese and Japanese for the matching locales, and in English for en-US and eo, which the catalog matches to its source language en. The window opened and pumped messages normally while the backend waited for the mount. Before the lower-case fix, the same probe set zh_CN and still showed English.

Screenshots

None. NSGo draws nothing different; WinSparkle's own dialogs now use the app's language.

@github-actions github-actions Bot added bug Something isn't working size/M documentation Improvements or additions to documentation Windows core macOS iOS Linux base cli ci labels Nov 15, 2026
@houko
houko force-pushed the fix/windows-update-language branch from b18bd1f to b41e3dc Compare November 16, 2026 03:08
WinSparkle 0.9.4 hands win_sparkle_set_lang's name to wxWidgets, which lists the translations in WinSparkle.dll by their lowered resource names and compares case-sensitively, so zh_CN, pt_BR and the other regional names found nothing and the dialogs stayed English on an English Windows. The names are now lower case (zh_cn), which a Windows 11 run showed in Simplified and Traditional Chinese, Brazilian Portuguese and Japanese.

English now maps to en, WinSparkle's own language, so an English app on a non-English Windows no longer gets the system language's dialogs. zh picks by script and pt defaults to Brazilian as CLDR infers them, and no maps to nb. Language's test asks before the first commit arrives, so it needs Language to wait for the mount, and checks it returns after Close. The docs say the language is taken once, at start, and the public building docs say Windows' updater uses the app's language.
Engine.Language waits on the UI thread for the app's mount, and it was evaluated for every Windows app, so an app without updates, or without WinSparkle.dll, held its message loop until the mount ended. startWinSparkle now takes the function and calls it only after the feed and the DLL are there, right before win_sparkle_set_lang.
@houko
houko force-pushed the fix/windows-update-language branch from b41e3dc to d6f2eb8 Compare November 16, 2026 04:32
@houko

houko commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. Checked the code against WinSparkle 0.9.4's sources and the wxWidgets commit it pins: win_sparkle_set_lang goes straight to wxTranslations::SetLanguage, EnumTranslations lowers the DLL's resource names (winsparkle_zh_CN becomes zh_cn) and DoGetBestAvailableTranslation looks m_lang up with a case-sensitive Index, so the lower-case names are required, and en matches the msgid language and shows English. The mapping table matches the 0.9.4 translations/ directory.

One change on top: w.engine.Language() was evaluated for every Windows app before startWinSparkle checked the feed, so apps without updates (or without WinSparkle.dll) blocked the UI thread until the mount finished. startWinSparkle now takes engine.Language as a function and calls it only right before win_sparkle_set_lang. Rebased onto current main (no conflicts).

Tests: with the first commit's mapping restored, TestWinSparkleLanguage fails (zh_CN, pt_BR, en as ""), and with a Language that reads the tree without waiting for the mount, TestLanguageReadsTheMountedApp fails with "". Both pass on the branch.

Builds and tests on the rebased head: every commit builds for darwin and windows/amd64; vet for windows/amd64 and js/wasm of the touched packages; windows/386 and windows/arm64 builds of internal/platform/windows; linux/amd64 and android/arm64 builds; go tool nsgo check -target all; go tool nsgo test on ./internal/platform/updates, ./internal/engine and ./core (all passed), and before the rebase also ./cmd/nsgo and -run 'Layer|Skills|Doc' ..

Device: Windows 11 x64 with an en-US UI, a probe app built from this branch with en, zh-Hans, zh-Hant, pt-BR and ja catalogs, the pinned WinSparkle 0.9.4 x64 DLL (hash checked), a locale set as the app mounts, and updater.Check against an unreachable feed. WinSparkle's error dialog showed in Simplified Chinese for zh-CN, Traditional Chinese for zh-TW and zh-Hant-CN, Brazilian Portuguese for pt-BR, Japanese for ja, and English for en-US. The main window opened and the dialog came up normally with the lazy language call. Not device-checked: an English app on a non-English Windows (the machine has only an English UI); that path is covered by the wxWidgets source and the unit test. Other platforms only gain the unused Engine.Language accessor.

@houko
houko marked this pull request as ready for review November 16, 2026 04:33
@houko
houko merged commit 7eba948 into main Nov 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

base bug Something isn't working ci cli core documentation Improvements or additions to documentation iOS Linux macOS size/M Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows updates: WinSparkle's dialogs follow the system language instead of the app's

1 participant