mirror of
https://github.com/open-webui/open-webui
synced 2025-01-29 13:58:09 +00:00
Merge pull request #2236 from akx/error-page-fix
fix: load i18n before showing error page
This commit is contained in:
commit
4f87512bbc
@ -37,7 +37,7 @@ const createIsLoadingStore = (i18n: i18nType) => {
|
|||||||
return isLoading;
|
return isLoading;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initI18n = (defaultLocale: string) => {
|
export const initI18n = (defaultLocale: string | undefined) => {
|
||||||
let detectionOrder = defaultLocale
|
let detectionOrder = defaultLocale
|
||||||
? ['querystring', 'localStorage']
|
? ['querystring', 'localStorage']
|
||||||
: ['querystring', 'localStorage', 'navigator'];
|
: ['querystring', 'localStorage', 'navigator'];
|
||||||
|
@ -21,20 +21,22 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
theme.set(localStorage.theme);
|
theme.set(localStorage.theme);
|
||||||
// Check Backend Status
|
let backendConfig = null;
|
||||||
const backendConfig = await getBackendConfig();
|
try {
|
||||||
|
backendConfig = await getBackendConfig();
|
||||||
|
console.log("Backend config:", backendConfig);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading backend config:", error);
|
||||||
|
}
|
||||||
|
// Initialize i18n even if we didn't get a backend config,
|
||||||
|
// so `/error` can show something that's not `undefined`.
|
||||||
|
initI18n(backendConfig?.default_locale);
|
||||||
|
|
||||||
if (backendConfig) {
|
if (backendConfig) {
|
||||||
// Save Backend Status to Store
|
// Save Backend Status to Store
|
||||||
await config.set(backendConfig);
|
await config.set(backendConfig);
|
||||||
if ($config.default_locale) {
|
|
||||||
initI18n($config.default_locale);
|
|
||||||
} else {
|
|
||||||
initI18n();
|
|
||||||
}
|
|
||||||
|
|
||||||
await WEBUI_NAME.set(backendConfig.name);
|
await WEBUI_NAME.set(backendConfig.name);
|
||||||
console.log(backendConfig);
|
|
||||||
|
|
||||||
if ($config) {
|
if ($config) {
|
||||||
if (localStorage.token) {
|
if (localStorage.token) {
|
||||||
|
Loading…
Reference in New Issue
Block a user