Repository navigation
Qt front end: ask Windows for the ISO language code, and regenerate the language table - #256
Merged
Merged
Conversation
…he language table Two bugs the PR review of #222 turned up in the current main: - `nspb_qt/i18n.py` asked `GetLocaleInfoW` for `0x02`, which is LOCALE_SLANGUAGE, the *localized display name*. On a Chinese Windows that answer is "中文(简体,中国)", the prefix test for "zh" never matched, and the early return handed the user an English interface — the very report the comment above the call says was fixed. The ISO 639 code is `0x59`, and the LANGID is masked with 0x3FF (the primary language) rather than 0xFF. - `nspb_qt/localization.py` was 18 keys behind `Localization.swift`: #246 added them to the Swift table without running `gen_localization.py`. They were never visible because the Windows bundle regenerates the table before packaging, but a source run of the Qt app showed the raw keys. Regenerated here. The Qt test job now regenerates the table and fails on any difference, so a string added to the Swift table cannot leave the Qt one stale again. Tests: `python -m unittest discover -s frontend-qt/tests` 179 tests OK. New: `test_windows_is_asked_for_the_iso_language_code` asserts the constant passed to the API (the existing test mocked only the answer, which is how 0x02 survived), and `test_a_windows_display_name_still_selects_the_language` covers zh/sv/de/en answers.
v0lumehi
approved these changes
Oct 30, 2026
v0lumehi
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, @LNPANDY, both findings are right, and the second one is on us: #246 added the strings without running gen_localization.py. The new check in the Qt job closes that gap for good.
Checked:
0x59isLOCALE_SISO639LANGNAMEand0x02isLOCALE_SLANGUAGE(the localized display name), so the old call could never matchzhon a Chinese Windows. The new test asserts the constant handed to the API, which is exactly what let0x02slip through before.& 0x3FFisPRIMARYLANGID, the right mask for a LANGID. Passing that primary id toGetLocaleInfoWasks for the neutral locale (0x0004for Chinese), which works on Vista and later. A small optional alternative is to pass the full LANGID unmasked, which is itself a valid LCID and avoids neutral locales entirely. Not a blocker.- The empty-answer case now falls through to the environment instead of returning English, which is better.
One thing to keep in mind with #225 (German): it adds Lang.DE to the Qt table, and test_a_windows_display_name_still_selects_the_language here expects de to give English. Whichever merges second needs a de branch in initial() and the test case changed to Lang.DE. I'll take care of that in #225 if this merges first, and #225 will also have to regenerate the table, which your new check now enforces.
Approving. As a fix it can merge once the remaining macOS jobs are green.
3 tasks done
2 of 3 tasks
2 tasks done
LNPANDY
added a commit
that referenced
this pull request
Oct 30, 2026
…n added Rebased onto current main and resolved the generated Qt table by regenerating it (gen_localization.py), so this keeps main's fixes rather than reverting them: - the ISO language code Windows is asked for (0x59), from #256 — without it a German Windows would still fall through to English on the Qt side - the 18 keys #246 added to the Swift table without regenerating the Qt one Ten strings had no German, because main added them after this branch was cut: `saves.macLibrary`, `saves.macStandard`, `saves.macPending`, `saves.noDevices`, `saves.notConnected`, `saves.timeout`, `saves.device`, `fail.zbic.what`, `fail.zbic.next` and `fail.zbic.button`. Two existing entries no longer matched the current English (`saves.reading`, `saves.notInstalled`): the first was missing its `%@`, the second still described an older sentence. Tests: swift test 500 tests, 0 failures; python -m unittest discover -s frontend-qt/tests 188 tests OK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Two bugs found reviewing #222 against current main.
A Chinese Windows got an English Qt interface.
frontend-qt/nspb_qt/i18n.pyaskedGetLocaleInfoWfor0x00000002, commented asLOCALE_SISO639LANGNAME.0x02isLOCALE_SLANGUAGE, the localized display name: on a Chinese Windows it answers中文(简体,中国), thestartswith('zh')test failed, and the early return chose English — so the fix described in the comment above the call never actually worked. The ISO 639 name is0x59. The LANGID is also now masked with0x3FF(the primary language) instead of0xFF.The Qt table was 18 keys behind the Swift one. #246 (823ca8b) added keys to
Localization.swiftwithout runninggen_localization.py. Invisible in the Windows bundle (it regenerates before packaging), but a source run of the Qt app showed those as raw keys. Regenerated here.The Qt test job now regenerates the table and fails on any difference, so this cannot drift again:
Checked
python -m unittest discover -s frontend-qt/tests— 179 tests OK.test_windows_is_asked_for_the_iso_language_codeasserts the constant handed to the API (the old test mocked only the answer, which is exactly how0x02survived);test_a_windows_display_name_still_selects_the_languagecoverszh,zh-Hans,sv,de,en-US.ctypes, as the existing tests do; the Windows bundle job builds and runs on tags only.Scope
frontend-qt/and.github/workflows/tests.ymlonly — no vendored file (dm/,scripts/,docs/,ref/,AGENTS.md) touched