Skip to content

Check that the code and en.json use the same keys, in both front ends (#388) - #481

Merged
v0lumehi merged 1 commit into
mainfrom
v0lumehi/l10n-key-checks
Nov 2, 2026
Merged

v0lumehi merged 1 commit into
mainfrom
v0lumehi/l10n-key-checks

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

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

Fix or feature

  • Fix
  • Feature

What and why

Part of #388, step 4.

Nothing checked that the keys in the code and the keys in en.json are the same. The Windows launcher showed the raw key msg.done after a successful build, because c198d056 removed it from the files while ui.py still asks for it. Now there is one key test per front end, both read the same rules file frontend/Tests/l10n-key-rules.json.

The rules:

  • A key that a lookup names (t("k"), loc.t("k"), L10n.string("k", ...), L10n.table["k"] in Swift, t('k') and self.m.t('k') in Python) is in en.json.
  • A key built at run time ("fail.\(kind).what", f'fail.{kind}.risk', "launch.set." + env) starts with an entry of dynamicKeys in the rules file. Every entry has at least one key in en.json and a string in the sources that starts with it.
  • A key of en.json that no source mentions, literally or under a dynamicKeys entry, fails. unusedAllowed in the rules file takes a key with the reason. It is empty now.
  • Both front ends count together, so a key only the Windows launcher uses is used.

Tests:

  • frontend/Tests/NXCoreTests/LocalizationKeyTests.swift (6 tests)
  • frontend-qt/tests/test_localization_keys.py (6 tests)

What it found, fixed in all five language files (sorted, flat, one entry per line):

  • Missing: msg.done and msg.ipaAt, used by ui.py. Added back. msg.done is now short ("Done", "完成", "Klart", "Fertig", "Terminé") because the old text promised three steps the Windows window does not have.
  • Unused, removed from all five files (26 keys): btn.build, btn.outDir, build.compatibility, build.details, build.files, build.output, build.resultIOS, build.resultMac, console.batteryUnknown, console.brand, console.connectedNextPlayer, console.fullscreen, console.mergeEach, console.playerMode, console.setup, dev.expiryExpiredShort, dev.expiryShort, dev.expiryTodayShort, dev.reinstall, dev.saveIPA, dev.signedApp, library.buildForMac, prog.empty, settings.appNote, settings.appNote2, shell.copyContinue.
  • Unused, removed: opt.macNoBc, opt.note, opt.title, and the five settings.language.<code> names that The language list comes from the language files (#388, step 2) #479 left behind (the picker reads the name from _language). The converter script is untouched.

Other changes:

  • The German, French, Swedish and dropdown tests that read settings.language.<code> or other removed keys now use Lang(code).name or drop the key from their lists. The German test of the language names is one test now.
  • The pre-push hook runs the Qt tests for a change under frontend/Sources/ and the rules file too, because the Qt test reads the Swift sources.
  • frontend/README.md says how the key rules work.

The iOS shell texts are not part of this step (step 5).

Checked

  • Tests: swift test in frontend passes except ConsoleTests.testFirstTileRingIsNotClippedAfterScrollingBack in one full run. It passes alone and in the other full run, so it is flaky and does not touch localization. Qt tests (237) and tools/tests (148) pass. The pre-push hook passes.
  • Visual QA: not applicable.
  • Run on a device or Mac: not run, tests only.

Screenshots

None, no visible change. The Windows build result line shows "Done" instead of the raw key, I did not capture it.

Scope

  • No engine file (dm/, scripts/, docs/, ref/) is added to the repository: a change there is a patch in patches/ (a commit in engine/, then tools/engine.py export, and tools/engine.py check passes), with its Upstream-Status
  • A fix to the engine or a game profile also goes to seedds/nxnative as a PR in parallel: this PR's patch says forwarded seedds/nxnative#..., or pending until that PR is open
  • A change to a launcher view has before and after screenshots above
  • No keys, game files or data extracted from a game in the change or the attachments

@v0lumehi v0lumehi added this to the v1.0.2 milestone Nov 2, 2026
@v0lumehi v0lumehi added enhancement New feature or request launcher The NX2Apple launcher app mac Mac windows Windows (the Qt front end) labels Nov 2, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 2, 2026
@v0lumehi
v0lumehi added this pull request to stack #459 November 2, 2026 05:42
Base automatically changed from v0lumehi/l10n-rules-tests to main November 2, 2026 17:14
…#388)

A lookup names only keys en.json has, a key built at run time needs a declared prefix, and a key no source uses fails.
The rules file frontend/Tests/l10n-key-rules.json is shared by the Mac and the Qt test.
Windows showed the key msg.done after a build, it is back in every language with msg.ipaAt.
26 keys no code used, the three opt.* ones and the settings.language.<code> names are removed from every language file.
@v0lumehi
v0lumehi force-pushed the v0lumehi/l10n-key-checks branch from 8359898 to 1349817 Compare November 2, 2026 17:14
@v0lumehi
v0lumehi merged commit 70a196e into main Nov 2, 2026
15 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/l10n-key-checks branch November 2, 2026 17:44
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