fix: translation without reloading (#1215)

* fix: translation without reloading

* fix: language switch
This commit is contained in:
Chell
2022-10-12 13:52:02 +02:00
committed by GitHub
parent 23f3fe1e3c
commit 8f7a8d7d4f
4 changed files with 7 additions and 4 deletions

View File

@ -74,6 +74,7 @@ import ModelEditPage from "./ModelEditPage";
import SystemInfo from "./SystemInfo";
import AdapterListPage from "./AdapterListPage";
import AdapterEditPage from "./AdapterEditPage";
import {withTranslation} from "react-i18next";
const {Header, Footer} = Layout;
@ -798,4 +799,4 @@ class App extends Component {
}
}
export default withRouter(App);
export default withRouter(withTranslation()(App));

View File

@ -554,7 +554,7 @@ export function changeLanguage(language) {
localStorage.setItem("language", language);
changeMomentLanguage(language);
i18next.changeLanguage(language);
window.location.reload(true);
// window.location.reload(true);
}
export function changeMomentLanguage(language) {

View File

@ -29,6 +29,7 @@ import i18next from "i18next";
import CustomGithubCorner from "../CustomGithubCorner";
import {CountDownInput} from "../common/CountDownInput";
import SelectLanguageBox from "../SelectLanguageBox";
import {withTranslation} from "react-i18next";
const {TabPane} = Tabs;
@ -730,4 +731,4 @@ class LoginPage extends React.Component {
}
}
export default LoginPage;
export default withTranslation()(LoginPage);

View File

@ -23,6 +23,7 @@ import ja from "./locales/ja/data.json";
import es from "./locales/es/data.json";
import * as Conf from "./Conf";
import * as Setting from "./Setting";
import {initReactI18next} from "react-i18next";
const resources = {
en: en,
@ -80,7 +81,7 @@ function initLanguage() {
return language;
}
i18n.init({
i18n.use(initReactI18next).init({
lng: initLanguage(),
resources: resources,