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
f55525c6
Commit
f55525c6
authored
Mar 07, 2024
by
Ased Mammad
Browse files
fix: load languages in an exported function
parent
c724e19e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
14 deletions
+18
-14
src/lib/components/chat/Settings/General.svelte
src/lib/components/chat/Settings/General.svelte
+3
-2
src/lib/i18n/index.ts
src/lib/i18n/index.ts
+5
-2
src/lib/i18n/locales/en/translation.json
src/lib/i18n/locales/en/translation.json
+0
-0
src/lib/i18n/locales/languages.json
src/lib/i18n/locales/languages.json
+10
-10
No files found.
src/lib/components/chat/Settings/General.svelte
View file @
f55525c6
<script lang="ts">
import { toast } from 'svelte-sonner';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import {
l
anguages } from '$lib/i18n';
import {
getL
anguages } from '$lib/i18n';
const dispatch = createEventDispatcher();
import { models, user } from '$lib/stores';
...
...
@@ -16,7 +16,7 @@
// General
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'];
let theme = 'dark';
// TODO: Get these dynamically from the i18n module
let languages = [];
let lang = $i18n.language;
let notificationEnabled = false;
let system = '';
...
...
@@ -69,6 +69,7 @@
onMount(async () => {
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
languages = await getLanguages();
theme = localStorage.theme ?? 'dark';
notificationEnabled = settings.notificationEnabled ?? false;
...
...
src/lib/i18n/index.ts
View file @
f55525c6
...
...
@@ -51,7 +51,7 @@ i18next
lookupLocalStorage
:
'
locale
'
},
fallbackLng
:
{
default
:
[
'
en
-US
'
]
default
:
[
'
en
'
]
},
ns
:
'
translation
'
,
interpolation
:
{
...
...
@@ -62,6 +62,9 @@ i18next
const
i18n
=
createI18nStore
(
i18next
);
const
isLoadingStore
=
createIsLoadingStore
(
i18next
);
export
const
languages
=
(
await
import
(
`./locales/languages.json`
)).
default
;
export
const
getLanguages
=
async
()
=>
{
const
languages
=
(
await
import
(
`./locales/languages.json`
)).
default
;
return
languages
;
};
export
default
i18n
;
export
const
isLoading
=
isLoadingStore
;
src/lib/i18n/locales/en
-US
/translation.json
→
src/lib/i18n/locales/en/translation.json
View file @
f55525c6
File moved
src/lib/i18n/locales/languages.json
View file @
f55525c6
[
{
"
titl
e"
:
"
English
"
,
"
cod
e"
:
"
en-US
"
"
cod
e"
:
"
en
"
,
"
titl
e"
:
"
English
"
},
{
"
titl
e"
:
"
فارسی
"
,
"
cod
e"
:
"
fa
"
"
cod
e"
:
"
fa
"
,
"
titl
e"
:
"
فارسی
"
},
{
"
titl
e"
:
"
Deutsch
"
,
"
cod
e"
:
"
de
"
"
cod
e"
:
"
de
"
,
"
titl
e"
:
"
Deutsch
"
},
{
"
titl
e"
:
"
French
"
,
"
cod
e"
:
"
fr
"
"
cod
e"
:
"
fr
"
,
"
titl
e"
:
"
French
"
},
{
"
titl
e"
:
"
Ukrainian
"
,
"
cod
e"
:
"
uk
"
"
cod
e"
:
"
uk
"
,
"
titl
e"
:
"
Ukrainian
"
}
]
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