Repository navigation
The language list comes from the language files (#388, step 2) - #479
Merged
Merged
Conversation
Lang is a value identified by its code in Swift and in Python, no longer an enum. The list, each language's own name and the locale prefixes that select it are read from the `_language` entries of frontend/l10n/*.json, so a new language is one new file for the Mac and Windows launchers. The picker, the device detection and the Qt language button read the list. Windows locale names stay in `_language.locales`. A new optional `order` keeps the picker's order for the five existing languages.
# Conflicts: # frontend-qt/nspb_qt/localization.py # frontend/Sources/NX2Apple/ContentView.swift # frontend/Sources/NXCore/Localization.swift # frontend/Sources/NXCore/ShellInstall.swift # frontend/Tests/NX2AppleTests/ShellInstallTests.swift
# Conflicts: # frontend/Sources/NXModel/BuildStore+ShellRoot.swift
# Conflicts: # AGENTS.md
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.
Stacked on #478 (stack #459), retarget to main after the ones below merge.
Part of #388, step 2.
Fix or feature
What and why
Step 2 of #388: the language list comes from the files.
Langstops being an enum in Swift and in Python. A new language is one new file underfrontend/l10n/for the Mac and the Windows launcher. The iOS shell's texts are step 5 and this PR does not touch them.What changes:
Langis astructidentified by its code.Lang.allis read from the files,namecomes from_language.nameandlocalesfrom_language.locales.Lang.zhandLang.enstay as the two required languages, English is still the fallback.Lang.find(code)replacesLang(rawValue:).Lang.detect(preferred:among:)picks the device language by locale prefix, so a test can feed it languages that exist only in a temporary folder.LocalizationFilesfinds the language files by listing the folder, so there is no list of five codes any more.appLanguagekey works as before:""follows the system, a code selects that language, an unknown code follows the system.[""] + Lang.alland shows each language's own name from the files. The "system" entry still follows the UI language. Thesettings.language.<code>strings stay in the files and are not read any more by the picker.frontend-qt):Langis a frozen dataclass of the code, not an enum.l10n.readlists the*.jsonfiles and gives the languages and the texts.Lang.all(),name,locales, the language button (other,toggle_label) andLang.initial()use them. The Windows locale names (german,deutsch,chinese,french,swedish) are matched from_language.locales.l10n.TABLEis nowkey: {code: text}instead of a fixed five-column tuple._languagegets an optionalorder(zh 0, en 1, sv 2, de 3, fr 4) so the picker keeps the order it always had. A language withoutordercomes after those with one, by code. No translated text changed.frontend/README.md,frontend/ARCHITECTURE.md,frontend-qt/README.mdandAGENTS.mdsay that a new language is one new file for the launchers.Checked
_language.localeslists, so no list needed an addition. A Python test feeds 59 old inputs (BCP-47 and POSIX tags, Windows locale names such asChinese (Simplified)_China,German_Germany,Deutsch (Deutschland),French (Canada)_Canada, and the ISO codes thatGetLocaleInfoWanswers) to the new code and to a copy of the old rules, and expects the same language. The Swift test does the same for 32 preferred-language lists. One edge differs on purpose in Python: a Windows ISO code is now matched like a tag (zhfollowed by a letter does not match), asfranddealready were.xx.json. The language is in the picker after the five, shows its own name, is selected by its locale prefix (and by a locale name), the five others still select theirs, and a text it lacks shows English. The Python test also starts a new process withNX_L10N_DIRset and checksLang.all(),NSPB_LANG=xxand a device languagexx_YY. Nothing outside the files changed for it.cd frontend && swift testthree times after the last change, all green, 880 tests over the three bundles (NXModelTests 118, NXCoreTests 118, NX2AppleTests 644 with 17 skipped captures), the previous step had 873 and the 7 new ones areLanguageListTests. The pre-push hook ran it a fourth time, green. An earlier run found one test of mine that still expected five reports for missing files, fixed before the commit.python3 -m unittest discover -s frontend-qt/tests: 226 tests OK (14 skipped).python3 -m unittest discover tools/tests: 148 OK.NX_LAUNCHER_CAPTURE_DIR=<dir> swift teston the base (One JSON file per language, read by the Mac and the Windows launcher (#388, step 1) #478) and on this branch, in en, zh, de, sv and fr, 78 views per language compared. Most are byte identical, including the Settings view with the language picker open (dropdown-settings). The rest differ only in boxes of single text lines where the checkout path is drawn (the two checkouts have different paths), a random temp path or a time of day. I looked at the Settings crop in both: same text and layout. One view in German (manage-menu-ipa-only) differs by a hover highlight with a maximum channel difference of 18, the text is the same.Screenshots
None, no visible change. I compared the launcher views before and after by pixel in all five languages (see Checked).
Scope
dm/,scripts/,docs/,ref/) is added to the repository