From 85e0f463fc264c5f6a337034a8f878095422f82f Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Wed, 9 Nov 2022 08:41:11 -0800 Subject: [PATCH] Process the locale to Electron later --- src/main.js | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/main.js b/src/main.js index 4d464258e7595e..40ce0fdec22619 100644 --- a/src/main.js +++ b/src/main.js @@ -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']) { @@ -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') { @@ -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]; @@ -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') { @@ -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