Repository navigation
Follow the system language when LANG is set - #2
Merged
Merged
Conversation
langParser() returned 'en' whenever LANG was defined. The check was a proxy for "running under mocha", but Linux desktop sessions and macOS terminals set LANG too, so the UI never followed the system language there: LANG=tr_TR.UTF-8 or zh_CN.UTF-8 still gave English. Use NODE_ENV=test as the test signal instead. WebdriverIO starts its spec workers with NODE_ENV=test unless it is already set, and the forge webpack build replaces process.env.NODE_ENV with "production" or "development", so the branch cannot run in the app. Everywhere else the language comes from Intl, which in Electron follows the application locale (LANGUAGE, LC_ALL, LC_MESSAGES and LANG on Linux) and which the macOS sudo prompt already uses.
celaldrg
force-pushed
the
fix/linux-language-detection
branch
from
October 29, 2026 08:17
030d3f8 to
45f1c64
Compare
celaldrg
force-pushed
the
fix/linux-language-detection
branch
from
October 29, 2026 08:26
45f1c64 to
2f3f8fd
Compare
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.
Problem
langParser()inlib/gui/app/i18n.tsreturned'en'wheneverprocess.env.LANGwas defined. Linux desktop sessions almost always setLANG, and so do macOS terminals, so on Linux the UI stayed in English for every locale: withLANG=tr_TR.UTF-8orLANG=zh_CN.UTF-8the function returneden. The renderer sends the same value to the main process (change-lng), so the menu stayed English too.Why the check existed
It came in 0f10f2d (2022), together with the first translations, as a "bypass mocha" switch: the specs ran under electron-mocha from a shell, where
LANGis set, and they assert English strings (tests/shared/messages.spec.tsstill does).LANGwas only a proxy for "running tests". Nothing else depends on it:tests/andwdio.conf.tsnever set or readLANG. Specs now run in WebdriverIO workers, and@wdio/local-runner8.36.1 forks them withNODE_ENV: process.env.NODE_ENV || 'test'.lib/shared/sudo/darwin.tspicks the macOS password prompt language fromIntlandsupportedLocalesand never looked atLANG. On a Mac started from a terminal, the UI was English while the password prompt followed the system language.Fix
Use
NODE_ENV === 'test'as the test signal instead of the presence ofLANG. In every other case the language comes fromIntl, exactly as it did before whenLANGwas unset.LANGis usually unset and the old check did nothing.modeset toproduction(package/make) ordevelopment(start), and webpack'soptimization.nodeEnvthen replacesprocess.env.NODE_ENVwith that string.Intlfollows the application locale, which Chromium resolves fromLANGUAGE,LC_ALL,LC_MESSAGESandLANGon Linux and from the system language settings on Windows and macOS. The UI and the macOS password prompt now use the same source.Parsing
LANGinsidelangParser()was the other option. I did not take it because it would duplicate what Chromium already does, ignoreLANGUAGE, prefer a terminal'sLANGover the macOS system language, and still leave test runs depending on the developer's locale.Verification
npx balena-lint --typescript typings lib tests forge.config.ts forge.sidecar.ts forge.pkg-node.ts webpack.config.ts(without--fix): passed.npx tsc -p tsconfig.i18n.json: passed.lib/gui/app/i18n.tswith ts-node and calledlangParser()with differentLANG/NODE_ENVvalues and a stubbedIntllocale:LANG=tr_TR.UTF-8LANG=zh_CN.UTF-8LANG=zh_SG.UTF-8LANG=zh_TW.UTF-8LANG=zh_HK.UTF-8LANG=C.UTF-8LANG=en_US.UTF-8NODE_ENV=test,LANG=tr_TR.UTF-8NODE_ENV=test, noLANGNODE_ENV=test, noLANGNODE_ENV=productionordevelopment,LANG=tr_TR.UTF-8tests/shared/messages.spec.ts(English assertions, excluded from the wdio run) under plain mocha withIntlforced to zh-CN andLANG=zh_CN.UTF-8: 8 passing withNODE_ENV=test; without it, 6 failing with Chinese strings, which is what a user with that locale should now see.git merge-treewithfeat/turkish-ui: no conflicts.Not verified
Intllocale followingLANG/LANGUAGEon Linux: the fix relies on Chromium's locale resolution for that, which was not observed here.npm run wdiowas not run (install scripts were skipped, so there is no Electron binary).Notes
NODE_ENV=testto get English; before, anyLANGdid it.NODE_ENVis already set to another value when wdio starts, the workers keep it and the specs follow the system locale.🤖 Generated with Claude Code