Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: install select langs need change i18n

shuai9dd41b6248c8
diff --git a/ui/src/common/constants.ts b/ui/src/common/constants.ts
index b700ad54..028e56e8 100644
--- a/ui/src/common/constants.ts
+++ b/ui/src/common/constants.ts
@@ -1,5 +1,5 @@
export const DEFAULT_LANG = 'en_US';
-export const CURRENT_LANG_STORAGE_KEY = '_a_lang__';
+export const CURRENT_LANG_STORAGE_KEY = '_a_lang_';
export const LOGGED_USER_STORAGE_KEY = '_a_lui_';
export const LOGGED_TOKEN_STORAGE_KEY = '_a_ltk_';
export const REDIRECT_PATH_STORAGE_KEY = '_a_rp_';
diff --git a/ui/src/pages/Install/components/FirstStep/index.tsx b/ui/src/pages/Install/components/FirstStep/index.tsx
index 78b4aac8..e35a0f29 100644
--- a/ui/src/pages/Install/components/FirstStep/index.tsx
+++ b/ui/src/pages/Install/components/FirstStep/index.tsx
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import type { LangsType, FormValue, FormDataType } from '@/common/interface';
import Progress from '../Progress';
-import { getInstallLangOptions } from '@/services';
+import { getLanguageOptions } from '@/services';
interface Props {
data: FormValue;
@@ -18,7 +18,7 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
const [langs, setLangs] = useState<LangsType[]>();
const getLangs = async () => {
- const res: LangsType[] = await getInstallLangOptions();
+ const res: LangsType[] = await getLanguageOptions();
setLangs(res);
changeCallback({
lang: {
diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index 6201f2cd..00793fee 100644
--- a/ui/src/pages/Install/index.tsx
+++ b/ui/src/pages/Install/index.tsx
@@ -10,6 +10,8 @@ import {
installBaseInfo,
checkConfigFileExists,
} from '@/services';
+import { Storage } from '@/utils';
+import { CURRENT_LANG_STORAGE_KEY } from '@/common/constants';
import {
FirstStep,
@@ -170,13 +172,20 @@ const Index: FC = () => {
};
const handleStep = () => {
+ if (step === 1) {
+ Storage.set(CURRENT_LANG_STORAGE_KEY, formData.lang.value);
+ handleNext();
+ }
if (step === 2) {
submitDatabaseForm();
- } else if (step === 3) {
+ }
+ if (step === 3) {
checkInstall();
- } else if (step === 4) {
+ }
+ if (step === 4) {
submitSiteConfig();
- } else {
+ }
+ if (step > 4) {
handleNext();
}
};
diff --git a/ui/src/utils/localize.ts b/ui/src/utils/localize.ts
index 4a2b5c05..0c6313b6 100644
--- a/ui/src/utils/localize.ts
+++ b/ui/src/utils/localize.ts
@@ -2,7 +2,8 @@ import dayjs from 'dayjs';
import i18next from 'i18next';
import { interfaceStore, loggedUserInfoStore } from '@/stores';
-import { DEFAULT_LANG } from '@/common/constants';
+import { DEFAULT_LANG, CURRENT_LANG_STORAGE_KEY } from '@/common/constants';
+import { Storage } from '@/utils';
const localDayjs = (langName) => {
langName = langName.replace('_', '-').toLowerCase();
@@ -12,12 +13,13 @@ const localDayjs = (langName) => {
export const getCurrentLang = () => {
const loggedUser = loggedUserInfoStore.getState().user;
const adminInterface = interfaceStore.getState().interface;
+ const storageLang = Storage.get(CURRENT_LANG_STORAGE_KEY);
let currentLang = loggedUser.language;
// `default` mean use language value from admin interface
if (/default/i.test(currentLang) && adminInterface.language) {
currentLang = adminInterface.language;
}
- currentLang ||= DEFAULT_LANG;
+ currentLang ||= storageLang || DEFAULT_LANG;
return currentLang;
};