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
f4a18852
Commit
f4a18852
authored
Mar 07, 2024
by
Ased Mammad
Browse files
feat: Get available languages from json file
parent
41378748
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
6 deletions
+30
-6
src/lib/components/chat/Settings/General.svelte
src/lib/components/chat/Settings/General.svelte
+3
-4
src/lib/i18n/index.ts
src/lib/i18n/index.ts
+5
-2
src/lib/i18n/locales/de/translation.json
src/lib/i18n/locales/de/translation.json
+0
-0
src/lib/i18n/locales/en-US/translation.json
src/lib/i18n/locales/en-US/translation.json
+0
-0
src/lib/i18n/locales/fa/translation.json
src/lib/i18n/locales/fa/translation.json
+0
-0
src/lib/i18n/locales/fr/translation.json
src/lib/i18n/locales/fr/translation.json
+0
-0
src/lib/i18n/locales/languages.json
src/lib/i18n/locales/languages.json
+22
-0
src/lib/i18n/locales/uk/translation.json
src/lib/i18n/locales/uk/translation.json
+0
-0
No files found.
src/lib/components/chat/Settings/General.svelte
View file @
f4a18852
<script lang="ts">
<script lang="ts">
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { languages } from '$lib/i18n';
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher();
import { models, user } from '$lib/stores';
import { models, user } from '$lib/stores';
...
@@ -16,7 +17,6 @@
...
@@ -16,7 +17,6 @@
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'];
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'];
let theme = 'dark';
let theme = 'dark';
// TODO: Get these dynamically from the i18n module
// TODO: Get these dynamically from the i18n module
let languages = ['en', 'fa', 'fr', 'de', 'ua'];
let lang = $i18n.language;
let lang = $i18n.language;
let notificationEnabled = false;
let notificationEnabled = false;
let system = '';
let system = '';
...
@@ -134,12 +134,11 @@
...
@@ -134,12 +134,11 @@
bind:value={lang}
bind:value={lang}
placeholder="Select a language"
placeholder="Select a language"
on:change={(e) => {
on:change={(e) => {
console.log($i18n);
$i18n.changeLanguage(lang);
$i18n.changeLanguage(lang);
}}
}}
>
>
{#each languages as
valu
e}
{#each languages as
languag
e}
<option
{
value
}>{value
}</option>
<option value
={language['code']}>{language['title']
}</option>
{/each}
{/each}
</select>
</select>
</div>
</div>
...
...
src/lib/i18n/index.ts
View file @
f4a18852
...
@@ -50,13 +50,16 @@ i18next
...
@@ -50,13 +50,16 @@ i18next
lookupQuerystring
:
'
lang
'
,
lookupQuerystring
:
'
lang
'
,
lookupLocalStorage
:
'
locale
'
lookupLocalStorage
:
'
locale
'
},
},
fallbackLng
:
'
en
'
,
fallbackLng
:
{
ns
:
'
common
'
,
default
:
[
'
en-US
'
]
},
ns
:
'
translation
'
,
interpolation
:
{
interpolation
:
{
escapeValue
:
false
// not needed for svelte as it escapes by default
escapeValue
:
false
// not needed for svelte as it escapes by default
}
}
});
});
export
const
languages
=
(
await
import
(
`./locales/languages.json`
)).
default
;
const
i18n
=
createI18nStore
(
i18next
);
const
i18n
=
createI18nStore
(
i18next
);
const
isLoadingStore
=
createIsLoadingStore
(
i18next
);
const
isLoadingStore
=
createIsLoadingStore
(
i18next
);
export
default
i18n
;
export
default
i18n
;
...
...
src/lib/i18n/locales/de/
comm
on.json
→
src/lib/i18n/locales/de/
translati
on.json
View file @
f4a18852
File moved
src/lib/i18n/locales/en
/comm
on.json
→
src/lib/i18n/locales/en
-US/translati
on.json
View file @
f4a18852
File moved
src/lib/i18n/locales/fa/
comm
on.json
→
src/lib/i18n/locales/fa/
translati
on.json
View file @
f4a18852
File moved
src/lib/i18n/locales/fr/
comm
on.json
→
src/lib/i18n/locales/fr/
translati
on.json
View file @
f4a18852
File moved
src/lib/i18n/locales/languages.json
0 → 100644
View file @
f4a18852
[
{
"title"
:
"English"
,
"code"
:
"en-US"
},
{
"title"
:
"فارسی"
,
"code"
:
"fa"
},
{
"title"
:
"Deutsch"
,
"code"
:
"de"
},
{
"title"
:
"French"
,
"code"
:
"fr"
},
{
"title"
:
"Ukrainian"
,
"code"
:
"uk"
}
]
src/lib/i18n/locales/u
a/comm
on.json
→
src/lib/i18n/locales/u
k/translati
on.json
View file @
f4a18852
File moved
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