Prefix preferred system locales with l10n_util logic

This commit is contained in:
Jamie Kyle 2023-02-02 12:09:34 -08:00 committed by GitHub
parent e51f582bfb
commit ab7ab91429
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -55,8 +55,8 @@ export function load({
preferredSystemLocales: Array<string>;
logger: Pick<LoggerType, 'error' | 'warn' | 'info'>;
}): LocaleType {
if (preferredSystemLocales.length === 0) {
throw new TypeError('`appLocale` is required');
if (preferredSystemLocales == null) {
throw new TypeError('`preferredSystemLocales` is required');
}
if (!logger || !logger.error) {
@ -66,6 +66,10 @@ export function load({
throw new TypeError('`logger.warn` is required');
}
if (preferredSystemLocales.length === 0) {
logger.warn('`preferredSystemLocales` was empty');
}
const english = getLocaleMessages('en');
for (const locale of preferredSystemLocales) {

View file

@ -1619,7 +1619,11 @@ ipc.on('database-error', (_event: Electron.Event, error: string) => {
function loadPreferredSystemLocales(): Array<string> {
return getEnvironment() === Environment.Test
? ['en']
: app.getPreferredSystemLanguages();
: [
// TODO(DESKTOP-4929): Temp fix to inherit Chromium's l10n_util logic
app.getLocale(),
...app.getPreferredSystemLanguages(),
];
}
async function getDefaultLoginItemSettings(): Promise<LoginItemSettingsOptions> {
@ -1676,7 +1680,7 @@ app.on('ready', async () => {
logger.info(
`app.ready: preferred system locales: ${preferredSystemLocales.join(
', '
)}}`
)}`
);
resolvedTranslationsLocale = loadLocale({
preferredSystemLocales,