mirror of
https://github.com/open-webui/open-webui
synced 2025-04-06 21:54:55 +00:00
feat: auto detect user language
This commit is contained in:
parent
f755f5e512
commit
27f034b216
@ -13,7 +13,7 @@
|
|||||||
import 'tippy.js/dist/tippy.css';
|
import 'tippy.js/dist/tippy.css';
|
||||||
|
|
||||||
import { WEBUI_BASE_URL } from '$lib/constants';
|
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||||
import i18n, { initI18n } from '$lib/i18n';
|
import i18n, { initI18n, getLanguages } from '$lib/i18n';
|
||||||
|
|
||||||
setContext('i18n', i18n);
|
setContext('i18n', i18n);
|
||||||
|
|
||||||
@ -43,7 +43,14 @@
|
|||||||
}
|
}
|
||||||
// Initialize i18n even if we didn't get a backend config,
|
// Initialize i18n even if we didn't get a backend config,
|
||||||
// so `/error` can show something that's not `undefined`.
|
// so `/error` can show something that's not `undefined`.
|
||||||
initI18n(backendConfig?.default_locale);
|
|
||||||
|
const languages = await getLanguages();
|
||||||
|
|
||||||
|
const browserLanguage = navigator.languages
|
||||||
|
? navigator.languages[0]
|
||||||
|
: navigator.language || navigator.userLanguage;
|
||||||
|
|
||||||
|
initI18n(languages.includes(browserLanguage) ? browserLanguage : backendConfig?.default_locale);
|
||||||
|
|
||||||
if (backendConfig) {
|
if (backendConfig) {
|
||||||
// Save Backend Status to Store
|
// Save Backend Status to Store
|
||||||
|
Loading…
Reference in New Issue
Block a user