Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass display language as a locale to Electron #159958

Merged
merged 10 commits into from
Nov 14, 2022
Prev Previous commit
Next Next commit
Pass the locale to Electron later
  • Loading branch information
rzhao271 committed Nov 9, 2022
commit 422fce8d872d6d0d5d22dd91b106e5d3bf4184b7
37 changes: 12 additions & 25 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ if (locale) {
nlsConfigurationPromise = getNLSConfiguration(product.commit, userDataPath, metaDataFile, locale);
}

if (product.quality === 'insider' || product.quality === 'exploration') {
// Pass in the locale to Electron so that the
// Windows Control Overlay is rendered correctly on Windows,
// and so that the traffic lights are rendered properly
// on macOS when using a custom titlebar.
// If the locale is `qps-ploc`, the Microsoft
// Pseudo Language Language Pack is being used.
// In that case, use `en` as the Electron locale.
const electronLocale = (!locale || locale === 'qps-ploc') ? 'en' : locale;
app.commandLine.appendSwitch('lang', electronLocale);
}

// Load our code once ready
app.once('ready', function () {
if (args['trace']) {
Expand Down Expand Up @@ -157,9 +169,6 @@ function configureCommandlineSwitchesSync(cliArgs) {

// override for the color profile to use
'force-color-profile',

// locale for Electron to use
'locale'
];

if (process.platform === 'linux') {
Expand All @@ -180,8 +189,6 @@ function configureCommandlineSwitchesSync(cliArgs) {
// Read argv config
const argvConfig = readArgvConfigSync();

let hasLocaleSwitch = false;
const isInsiderOrExploration = product.quality === 'insider' || product.quality === 'exploration';
Object.keys(argvConfig).forEach(argvKey => {
const argvValue = argvConfig[argvKey];

Expand All @@ -195,21 +202,6 @@ function configureCommandlineSwitchesSync(cliArgs) {
}
}

// Locale
else if (argvKey === 'locale') {
if (isInsiderOrExploration) {
// Pass in the locale to Electron so that the
// Windows Control Overlay is rendered correctly.
// If the locale is `qps-ploc`, the Microsoft
// Pseudo Language Language Pack is being used.
// In that case, use `en` as the Electron locale.
const localeToUse = (!argvValue || argvValue === 'qps-ploc') ?
'en' : argvValue;
app.commandLine.appendSwitch('lang', localeToUse);
hasLocaleSwitch = true;
}
}

// Others
else if (argvValue === true || argvValue === 'true') {
if (argvKey === 'disable-hardware-acceleration') {
Expand Down Expand Up @@ -240,11 +232,6 @@ function configureCommandlineSwitchesSync(cliArgs) {
}
});

if (!hasLocaleSwitch && isInsiderOrExploration) {
// Default Electron's locale to English
app.commandLine.appendSwitch('lang', 'en');
}

/* Following features are disabled from the runtime.
* `CalculateNativeWinOcclusion` - Disable native window occlusion tracker,
* Refs https://groups.google.com/a/chromium.org/g/embedder-dev/c/ZF3uHHyWLKw/m/VDN2hDXMAAAJ
Expand Down