Skip to content

Commit e47d11a

Browse files
committed
refactor(web): applying the language setting reuses the locale load path
1 parent 4d35201 commit e47d11a

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

‎apps/web/src/i18n/locales.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,3 @@ export function resolveLocale(language: string, systemLocales: ReadonlyArray<str
3535
}
3636
return DEFAULT_LOCALE;
3737
}
38-
39-
// Not desktopBridge.getSystemLocale(): that is the regional/time locale, not the UI language.
40-
export function readSystemLocales(): ReadonlyArray<string> {
41-
return navigator.languages;
42-
}

‎apps/web/src/i18n/runtime.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
updateClientSettings,
77
} from "../hooks/useSettings";
88
import { initializeI18n } from "./initializeI18n";
9-
import { DEFAULT_LOCALE, readSystemLocales, resolveLocale } from "./locales";
9+
import { DEFAULT_LOCALE, resolveLocale } from "./locales";
1010

1111
type LocaleTranslations = Awaited<ReturnType<typeof getTranslationsSnapshot>>;
1212

@@ -50,13 +50,9 @@ function activateLocale(locale: string): void {
5050
}
5151

5252
function applyLanguageSetting(): void {
53-
const locale = resolveLocale(getClientSettings().language, readSystemLocales());
54-
requestedLocale = locale;
55-
if (locale in loadedTranslations) {
56-
activateLocale(locale);
57-
return;
58-
}
59-
void loadLocale(locale).then(() => activateLocale(locale));
53+
// Not desktopBridge.getSystemLocale(): that is the regional/time locale, not the UI language.
54+
requestedLocale = resolveLocale(getClientSettings().language, navigator.languages);
55+
void whenLocaleReady();
6056
}
6157

6258
/** GT's own locale setters write the saved setting, which stays the only source of truth. */

0 commit comments

Comments
 (0)