Skip to content

The language list comes from the language files (#388, step 2) - #479

Merged
v0lumehi merged 7 commits into
v0lumehi/l10n-jsonfrom
v0lumehi/l10n-language-list
Nov 2, 2026
Merged

v0lumehi merged 7 commits into
v0lumehi/l10n-jsonfrom
v0lumehi/l10n-language-list

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #478 (stack #459), retarget to main after the ones below merge.

Part of #388, step 2.

Fix or feature

  • Fix
  • Feature

What and why

Step 2 of #388: the language list comes from the files. Lang stops being an enum in Swift and in Python. A new language is one new file under frontend/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:

  • Swift: Lang is a struct identified by its code. Lang.all is read from the files, name comes from _language.name and locales from _language.locales. Lang.zh and Lang.en stay as the two required languages, English is still the fallback. Lang.find(code) replaces Lang(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. LocalizationFiles finds the language files by listing the folder, so there is no list of five codes any more.
  • The appLanguage key works as before: "" follows the system, a code selects that language, an unknown code follows the system.
  • The Settings picker is [""] + Lang.all and shows each language's own name from the files. The "system" entry still follows the UI language. The settings.language.<code> strings stay in the files and are not read any more by the picker.
  • Python (frontend-qt): Lang is a frozen dataclass of the code, not an enum. l10n.read lists the *.json files and gives the languages and the texts. Lang.all(), name, locales, the language button (other, toggle_label) and Lang.initial() use them. The Windows locale names (german, deutsch, chinese, french, swedish) are matched from _language.locales. l10n.TABLE is now key: {code: text} instead of a fixed five-column tuple.
  • The files: each _language gets an optional order (zh 0, en 1, sv 2, de 3, fr 4) so the picker keeps the order it always had. A language without order comes after those with one, by code. No translated text changed.
  • Docs: frontend/README.md, frontend/ARCHITECTURE.md, frontend-qt/README.md and AGENTS.md say that a new language is one new file for the launchers.

Checked

  • Detection compatibility. Every name the old Swift and Python detection handled is still in the _language.locales lists, so no list needed an addition. A Python test feeds 59 old inputs (BCP-47 and POSIX tags, Windows locale names such as Chinese (Simplified)_China, German_Germany, Deutsch (Deutschland), French (Canada)_Canada, and the ISO codes that GetLocaleInfoW answers) 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 (zh followed by a letter does not match), as fr and de already were.
  • Six languages. A test in each front end copies the five files and adds a temporary 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 with NX_L10N_DIR set and checks Lang.all(), NSPB_LANG=xx and a device language xx_YY. Nothing outside the files changed for it.
  • The picker list in the five real files is the same names in the same order as before: 中文, English, Svenska, Deutsch, Français. The Qt button cycles zh, en, sv, de, fr and its labels are EN, Svenska, Deutsch, Français, 中文 as before.
  • Tests: cd frontend && swift test three 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 are LanguageListTests. 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.
  • Visual QA: NX_LAUNCHER_CAPTURE_DIR=<dir> swift test on 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.
  • Run on a Mac or Windows: not run. The release app and the Windows build are not built here.

Screenshots

None, no visible change. I compared the launcher views before and after by pixel in all five languages (see Checked).

Scope

  • No engine file (dm/, scripts/, docs/, ref/) is added to the repository
  • No engine change, no patch
  • No launcher view changes, so no screenshots are needed
  • No keys, game files or data extracted from a game in the change

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
@v0lumehi
v0lumehi merged commit d9ae970 into main Nov 2, 2026
16 of 28 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/l10n-language-list branch November 2, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request launcher The NX2Apple launcher app mac Mac windows Windows (the Qt front end)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant