Skip to content

Commit

Permalink
Add en as fallback osLocale (#175039)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 authored Feb 22, 2023
1 parent 492e7d5 commit 7b6b686
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 1 addition & 3 deletions test/smoke/src/areas/workbench/localization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7b6b686

Please sign in to comment.