Repository navigation
fix(windows): localize WinSparkle dialogs - #300
Conversation
b18bd1f to
b41e3dc
Compare
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.
b41e3dc to
d6f2eb8
Compare
|
Reviewed. Checked the code against WinSparkle 0.9.4's sources and the wxWidgets commit it pins: One change on top: Tests: with the first commit's mapping restored, 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; 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 |
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.Languageandengine.Engine.Languagereturn the language the app shows (core.Env.Language).Engine.Languagewaits 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.updates.WinSparkleLanguage's name towin_sparkle_set_langbeforewin_sparkle_init.updates.WinSparkleLanguagemaps a catalog language to a translation WinSparkle 0.9.4 ships (itstranslations/directory). Names are lower case (zh_cn, notzh_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/zhmap tozh_cnandzh-Hant/zh-TW/zh-HKtozh_tw(by script, inferred when the tag leaves it out),ptandpt-BRtopt_br,pt-PTtopt_pt,sr-Latntosr@latin,notonb,ca/fy/glto their regional files, and other shipped languages by their base (de-CHtode).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.docs/architecture/updates.mdsays 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 ofinternal/platform/windows;go tool nsgo check -target all.go tool nsgo teston./internal/platform/updates,./internal/engine,./core,./cmd/nsgo, and-run 'Layer|Skills|Doc' ..TestWinSparkleLanguagecovers the mapping, its lower case, English and unsupported languages.TestLanguageReadsTheMountedAppasks before the first commit arrives, so it needsLanguageto wait for the mount, and checks that it returns afterClose.en-USandeo, which the catalog matches to its source languageen. The window opened and pumped messages normally while the backend waited for the mount. Before the lower-case fix, the same probe setzh_CNand still showed English.Screenshots
None. NSGo draws nothing different; WinSparkle's own dialogs now use the app's language.