fixed: 编译无法切换语言
This commit is contained in:
parent
381e1f16d1
commit
07d3bb2bb9
@ -3,9 +3,10 @@ import {initReactI18next} from 'react-i18next';
|
|||||||
import LangEN from './translations/en-US.json';
|
import LangEN from './translations/en-US.json';
|
||||||
import LangCN from './translations/zh-CN.json';
|
import LangCN from './translations/zh-CN.json';
|
||||||
|
|
||||||
console.log('AppConfig',AppMode)
|
console.log('AppConfig',AppMode,AppConfig)
|
||||||
i18next.use(initReactI18next).init({
|
i18next.use(initReactI18next).init({
|
||||||
debug: true,
|
debug: true,
|
||||||
|
lng: (AppConfig.APP_LANG || 'zh-CN').trim(),
|
||||||
fallbackLng: 'en-US',
|
fallbackLng: 'en-US',
|
||||||
resources: {
|
resources: {
|
||||||
'en-US': {translation:LangEN},
|
'en-US': {translation:LangEN},
|
||||||
|
@ -31,16 +31,16 @@ const router = createBrowserRouter([
|
|||||||
const {globalConfig} = useGlobalConfig();
|
const {globalConfig} = useGlobalConfig();
|
||||||
// future={{v7_startTransition: true,v7_relativeSplatPath: true}}
|
// future={{v7_startTransition: true,v7_relativeSplatPath: true}}
|
||||||
const AppRouter = () => {
|
const AppRouter = () => {
|
||||||
const {t,i18n:langConfig} = useTranslation();
|
const {t,i18n} = useTranslation();
|
||||||
const {i18n} = useConfig();
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (i18n && i18n == 'zh-CN') {
|
if (i18n && i18n.language == 'zh-CN') {
|
||||||
dayjs.locale('zh-cn');
|
dayjs.locale('zh-cn');
|
||||||
}else{
|
}else{
|
||||||
dayjs.locale('en')
|
dayjs.locale('en')
|
||||||
}
|
}
|
||||||
globalConfig.i18n = i18n
|
globalConfig.i18n = i18n.language
|
||||||
langConfig.changeLanguage(i18n).then(()=>console.log('change lang to ',i18n))
|
// i18n.changeLanguage(i18n).then(()=>console.log('change lang to ',i18n))
|
||||||
}, [i18n])
|
}, [i18n])
|
||||||
|
|
||||||
return (<ConfigProvider
|
return (<ConfigProvider
|
||||||
|
Loading…
x
Reference in New Issue
Block a user