I18n: Completed i18n&&proofread some translations (#2619)

* i18n-1

* i18n: Completed the remaining parts of i18n and proofread some translations

* i18n: add default lang&&add app template i18n
This commit is contained in:
papapatrick
2024-09-05 17:29:36 +08:00
committed by GitHub
parent b4238257b6
commit dfcffc7fc1
30 changed files with 1590 additions and 1546 deletions

View File

@@ -4,7 +4,7 @@ import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import type { FastGPTFeConfigsType } from '@fastgpt/global/common/system/types/index.d';
import { change2DefaultLng, setLngStore } from '@/web/common/utils/i18n';
import { change2DefaultLng, LangEnum, setLngStore } from '@/web/common/utils/i18n';
import { useMemoizedFn, useMount } from 'ahooks';
import { TrackEventName } from '../common/system/constants';
@@ -40,11 +40,13 @@ export const useInitApp = () => {
const initUserLanguage = useMemoizedFn(() => {
// get default language
const targetLng = change2DefaultLng(i18n.language);
if (targetLng) {
setLngStore(targetLng);
router.replace(router.asPath, undefined, { locale: targetLng });
}
const targetLng =
change2DefaultLng(i18n.language) ||
(['zh', 'zh-CN'].includes(navigator.language) ? 'zh' : 'en');
setLngStore(targetLng);
router.replace(router.asPath, undefined, { locale: targetLng });
});
useMount(() => {