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:
chengyongruandovo-agentx authored and GitHub committed 2026-11-07 00:46:09 +08:00
1 parent 0ee302253f
commit 12c7d116a0
6 files changed
+108 -8

No files matched your search

+3 -1
View File
@@ -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 {
+1 -1
View File
@@ -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;