From e04b19409245503e8977adbe326bb995d8e5f7d5 Mon Sep 17 00:00:00 2001
From: "morris.liu" <8832717+realMorrisLiu@users.noreply.github.com>
Date: Mon, 9 Jan 2023 16:47:45 +0800
Subject: [PATCH 1/2] fix: fix avatar squash in users page
---
ui/src/pages/Users/index.tsx | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ui/src/pages/Users/index.tsx b/ui/src/pages/Users/index.tsx
index d454948e..b3c73303 100644
--- a/ui/src/pages/Users/index.tsx
+++ b/ui/src/pages/Users/index.tsx
@@ -51,7 +51,11 @@ const Users = () => {
className="mb-4">
-
+
From 6eff356eca6ba7c4559c38040026a283a9d85fad Mon Sep 17 00:00:00 2001
From: haitaoo
Date: Fri, 10 Feb 2023 11:53:50 +0800
Subject: [PATCH 2/2] fix(i18n): Fixes for multilingual file loading and
updating issues
---
ui/src/utils/guard.ts | 2 +-
ui/src/utils/localize.ts | 24 ++++++++++++++----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/ui/src/utils/guard.ts b/ui/src/utils/guard.ts
index 3ca73e0e..f2867378 100644
--- a/ui/src/utils/guard.ts
+++ b/ui/src/utils/guard.ts
@@ -283,7 +283,7 @@ export const setupApp = async () => {
// TODO: optimize `initAppSettingsStore` by server render
if (shouldInitAppFetchData()) {
await Promise.allSettled([pullLoggedUser(), initAppSettingsStore()]);
- setupAppLanguage();
+ await setupAppLanguage();
setupAppTimeZone();
}
};
diff --git a/ui/src/utils/localize.ts b/ui/src/utils/localize.ts
index 5071ee9d..e6b9fc89 100644
--- a/ui/src/utils/localize.ts
+++ b/ui/src/utils/localize.ts
@@ -31,8 +31,17 @@ export const loadLanguageOptions = async (forAdmin = false) => {
return languageOptions;
};
+const pullLanguageConf = (res) => {
+ return getLanguageConfig().then((langConf) => {
+ if (langConf && langConf.ui) {
+ res.resources = langConf.ui;
+ Storage.set(LANG_RESOURCE_STORAGE_KEY, res);
+ }
+ });
+};
const addI18nResource = async (langName) => {
const res = { lng: langName, resources: undefined };
+ const storageResource = Storage.get(LANG_RESOURCE_STORAGE_KEY);
if (process.env.NODE_ENV === 'development') {
try {
const { default: resConf } = await import(`@i18n/${langName}.yaml`);
@@ -40,17 +49,13 @@ const addI18nResource = async (langName) => {
} catch (ex) {
console.log('ex: ', ex);
}
+ } else if (storageResource && storageResource.lng === res.lng) {
+ res.resources = storageResource.resources;
+ pullLanguageConf(res);
} else {
- const storageResource = Storage.get(LANG_RESOURCE_STORAGE_KEY);
- if (storageResource?.lng === res.lng) {
- res.resources = storageResource.resources;
- } else {
- const langConf = await getLanguageConfig();
- if (langConf) {
- res.resources = langConf;
- }
- }
+ await pullLanguageConf(res);
}
+
if (res.resources) {
i18next.addResourceBundle(
res.lng,
@@ -59,7 +64,6 @@ const addI18nResource = async (langName) => {
true,
true,
);
- Storage.set(LANG_RESOURCE_STORAGE_KEY, res);
}
};