Skip to content

Commit

Permalink
Pass the locale to Electron later
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Nov 9, 2022
1 parent 0f71a7c commit 422fce8
Showing 1 changed file with 12 additions and 25 deletions.
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

0 comments on commit 422fce8

Please sign in to comment.