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 LangCN from './translations/zh-CN.json';
|
||||
|
||||
console.log('AppConfig',AppMode)
|
||||
console.log('AppConfig',AppMode,AppConfig)
|
||||
i18next.use(initReactI18next).init({
|
||||
debug: true,
|
||||
lng: (AppConfig.APP_LANG || 'zh-CN').trim(),
|
||||
fallbackLng: 'en-US',
|
||||
resources: {
|
||||
'en-US': {translation:LangEN},
|
||||
|
@ -31,16 +31,16 @@ const router = createBrowserRouter([
|
||||
const {globalConfig} = useGlobalConfig();
|
||||
// future={{v7_startTransition: true,v7_relativeSplatPath: true}}
|
||||
const AppRouter = () => {
|
||||
const {t,i18n:langConfig} = useTranslation();
|
||||
const {i18n} = useConfig();
|
||||
const {t,i18n} = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
if (i18n && i18n == 'zh-CN') {
|
||||
if (i18n && i18n.language == 'zh-CN') {
|
||||
dayjs.locale('zh-cn');
|
||||
}else{
|
||||
dayjs.locale('en')
|
||||
}
|
||||
globalConfig.i18n = i18n
|
||||
langConfig.changeLanguage(i18n).then(()=>console.log('change lang to ',i18n))
|
||||
globalConfig.i18n = i18n.language
|
||||
// i18n.changeLanguage(i18n).then(()=>console.log('change lang to ',i18n))
|
||||
}, [i18n])
|
||||
|
||||
return (<ConfigProvider
|
||||
|
Loading…
x
Reference in New Issue
Block a user