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
d9a229b1
Commit
d9a229b1
authored
Jun 30, 2024
by
Timothy J. Baek
Browse files
fix: default locale
parent
f6efda9e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
9 deletions
+17
-9
backend/config.py
backend/config.py
+7
-0
backend/main.py
backend/main.py
+3
-8
src/routes/+layout.svelte
src/routes/+layout.svelte
+7
-1
No files found.
backend/config.py
View file @
d9a229b1
...
...
@@ -674,6 +674,13 @@ ENABLE_SIGNUP = PersistentConfig(
else
os
.
environ
.
get
(
"ENABLE_SIGNUP"
,
"True"
).
lower
()
==
"true"
),
)
DEFAULT_LOCALE
=
PersistentConfig
(
"DEFAULT_LOCALE"
,
"ui.default_locale"
,
os
.
environ
.
get
(
"DEFAULT_LOCALE"
,
""
),
)
DEFAULT_MODELS
=
PersistentConfig
(
"DEFAULT_MODELS"
,
"ui.default_models"
,
os
.
environ
.
get
(
"DEFAULT_MODELS"
,
None
)
)
...
...
backend/main.py
View file @
d9a229b1
...
...
@@ -99,8 +99,10 @@ from config import (
CHANGELOG
,
FRONTEND_BUILD_DIR
,
UPLOAD_DIR
,
CACHE_DIR
,
STATIC_DIR
,
DEFAULT_LOCALE
,
ENABLE_OPENAI_API
,
ENABLE_OLLAMA_API
,
ENABLE_MODEL_FILTER
,
...
...
@@ -1722,18 +1724,11 @@ async def update_pipeline_valves(
@
app
.
get
(
"/api/config"
)
async
def
get_app_config
():
# Checking and Handling the Absence of 'ui' in CONFIG_DATA
default_locale
=
"en-US"
if
"ui"
in
CONFIG_DATA
:
default_locale
=
CONFIG_DATA
[
"ui"
].
get
(
"default_locale"
,
"en-US"
)
# The Rest of the Function Now Uses the Variables Defined Above
return
{
"status"
:
True
,
"name"
:
WEBUI_NAME
,
"version"
:
VERSION
,
"default_locale"
:
default_locale
,
"default_locale"
:
str
(
DEFAULT_LOCALE
)
,
"default_models"
:
webui_app
.
state
.
config
.
DEFAULT_MODELS
,
"default_prompt_suggestions"
:
webui_app
.
state
.
config
.
DEFAULT_PROMPT_SUGGESTIONS
,
"features"
:
{
...
...
src/routes/+layout.svelte
View file @
d9a229b1
...
...
@@ -96,8 +96,14 @@
const browserLanguages = navigator.languages
? navigator.languages
: [navigator.language || navigator.userLanguage];
const lang = backendConfig.default_locale
? backendConfig.default_locale
: bestMatchingLanguage(languages, browserLanguages, 'en-US');
initI18n(bestMatchingLanguage(languages, browserLanguages, backendConfig.default_locale));
initI18n();
if (!localStorage.locale) {
$i18n.changeLanguage(lang);
}
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