Add en as fallback osLocale (#175039)

This commit is contained in:
Raymond Zhao 2023-02-21 17:26:37 -08:00 committed by GitHub
parent 492e7d5e33
commit 7b6b6869e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -103,10 +103,12 @@ let osLocale = undefined;
// Ref https://github.com/microsoft/vscode/issues/159813
// and https://github.com/electron/electron/pull/36035
if ('getPreferredSystemLanguages' in app
&& typeof app.getPreferredSystemLanguages === 'function'
&& app.getPreferredSystemLanguages().length) {
&& typeof app.getPreferredSystemLanguages === 'function') {
// Use the most preferred OS language for language recommendation.
osLocale = app.getPreferredSystemLanguages()[0];
// The API might return an empty array on Linux, such as when
// the 'C' locale is the user's only configured locale.
// No matter the OS, if the array is empty, default back to 'en'.
osLocale = app.getPreferredSystemLanguages()?.[0] ?? 'en';
if (osLocale) {
osLocale = processZhLocale(osLocale.toLowerCase());
}

View file

@ -8,9 +8,7 @@ import { installAllHandlers } from '../../utils';
export function setup(logger: Logger) {
// BUG: app.getPreferredSystemLanguages() doesn't seem to return anything here on Linux: https://github.com/microsoft/vscode/blob/3ba29f37d6b9f3f2257b48f2b90f0699ea581be4/src/main.js#L100-L113
// but it should when we move to Electron 22 so we can re-enable this test then.
(process.platform === 'linux' ? describe.skip : describe)('Localization', () => {
describe('Localization', () => {
// Shared before/after handling
installAllHandlers(logger);