Prefix preferred system locales with l10n_util logic
This commit is contained in:
parent
e51f582bfb
commit
ab7ab91429
2 changed files with 12 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue