fix(webui): follow browser language on first visit (#6591)
Co-authored-by: ovo-agentx <351813579+ovo-agentx@users.noreply.github.com>
This commit is contained in:
1 parent
0ee302253f
commit
12c7d116a0
6 files changed
+108
-8
No files matched your search
@@ -62,7 +62,9 @@ function readStoredLocale(): SupportedLocale | null {
|
||||
}
|
||||
|
||||
export function resolveInitialLocale(): SupportedLocale {
|
||||
return readStoredLocale() ?? defaultLocale;
|
||||
return readStoredLocale() ?? normalizeLocale(
|
||||
typeof navigator === "undefined" ? null : navigator.languages?.[0] || navigator.language,
|
||||
);
|
||||
}
|
||||
|
||||
export function persistLocale(locale: SupportedLocale): void {
|
||||
|
||||
@@ -122,12 +122,12 @@ export async function setAppLanguage(locale: SupportedLocale): Promise<void> {
|
||||
await initializeI18n();
|
||||
await loadLocaleResources(locale);
|
||||
await i18n.changeLanguage(locale);
|
||||
persistLocale(locale);
|
||||
}
|
||||
|
||||
function syncLocaleSideEffects(language: string) {
|
||||
const locale = normalizeLocale(language);
|
||||
applyDocumentLocale(locale);
|
||||
persistLocale(locale);
|
||||
}
|
||||
|
||||
export default i18n;
|
||||
Reference in new issue
Block a user