Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
27f034b2
Commit
27f034b2
authored
May 26, 2024
by
Timothy J. Baek
Browse files
feat: auto detect user language
parent
f755f5e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
src/routes/+layout.svelte
src/routes/+layout.svelte
+9
-2
No files found.
src/routes/+layout.svelte
View file @
27f034b2
...
...
@@ -13,7 +13,7 @@
import 'tippy.js/dist/tippy.css';
import { WEBUI_BASE_URL } from '$lib/constants';
import i18n, { initI18n } from '$lib/i18n';
import i18n, { initI18n
, getLanguages
} from '$lib/i18n';
setContext('i18n', i18n);
...
...
@@ -43,7 +43,14 @@
}
// Initialize i18n even if we didn't get a backend config,
// 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) {
// Save Backend Status to Store
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment