|
@@ -2,22 +2,38 @@ import { HashRouter as Router, Route } from 'react-router-dom';
|
|
|
import { Routes } from 'react-router-dom';
|
|
|
import { ConfigProvider } from 'antd';
|
|
|
import zhCN from 'antd/locale/zh_CN';
|
|
|
+import enUS from 'antd/locale/en_US';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
import mainRoutes from './mainRoute';
|
|
|
import debugRoutes from './debugRoute';
|
|
|
import Version from '../components/public/Version';
|
|
|
-import React from 'react';
|
|
|
+import { React, useEffect, useState } from 'react';
|
|
|
|
|
|
//定义的路由函数直接挂载到主页面上去
|
|
|
const HRoutes = function () {
|
|
|
let allRoutes;
|
|
|
+ const { t, i18n } = useTranslation();
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
allRoutes = mainRoutes.concat(debugRoutes);
|
|
|
} else {
|
|
|
allRoutes = mainRoutes;
|
|
|
}
|
|
|
+
|
|
|
+ const localeMap = {
|
|
|
+ zh: zhCN,
|
|
|
+ en: enUS,
|
|
|
+ };
|
|
|
+ const [currentLocale, setCurrentLocale] = useState(zhCN); //
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (i18n.language) {
|
|
|
+ setCurrentLocale(localeMap[i18n.language]);
|
|
|
+ }
|
|
|
+ }, [i18n.language]);
|
|
|
+
|
|
|
return (
|
|
|
- <ConfigProvider locale={zhCN}>
|
|
|
+ <ConfigProvider locale={currentLocale}>
|
|
|
<Version />
|
|
|
<Router>
|
|
|
<Routes>
|