mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
fix: translation without reloading (#1215)
* fix: translation without reloading * fix: language switch
This commit is contained in:
@ -74,6 +74,7 @@ import ModelEditPage from "./ModelEditPage";
|
|||||||
import SystemInfo from "./SystemInfo";
|
import SystemInfo from "./SystemInfo";
|
||||||
import AdapterListPage from "./AdapterListPage";
|
import AdapterListPage from "./AdapterListPage";
|
||||||
import AdapterEditPage from "./AdapterEditPage";
|
import AdapterEditPage from "./AdapterEditPage";
|
||||||
|
import {withTranslation} from "react-i18next";
|
||||||
|
|
||||||
const {Header, Footer} = Layout;
|
const {Header, Footer} = Layout;
|
||||||
|
|
||||||
@ -798,4 +799,4 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(App);
|
export default withRouter(withTranslation()(App));
|
||||||
|
@ -554,7 +554,7 @@ export function changeLanguage(language) {
|
|||||||
localStorage.setItem("language", language);
|
localStorage.setItem("language", language);
|
||||||
changeMomentLanguage(language);
|
changeMomentLanguage(language);
|
||||||
i18next.changeLanguage(language);
|
i18next.changeLanguage(language);
|
||||||
window.location.reload(true);
|
// window.location.reload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeMomentLanguage(language) {
|
export function changeMomentLanguage(language) {
|
||||||
|
@ -29,6 +29,7 @@ import i18next from "i18next";
|
|||||||
import CustomGithubCorner from "../CustomGithubCorner";
|
import CustomGithubCorner from "../CustomGithubCorner";
|
||||||
import {CountDownInput} from "../common/CountDownInput";
|
import {CountDownInput} from "../common/CountDownInput";
|
||||||
import SelectLanguageBox from "../SelectLanguageBox";
|
import SelectLanguageBox from "../SelectLanguageBox";
|
||||||
|
import {withTranslation} from "react-i18next";
|
||||||
|
|
||||||
const {TabPane} = Tabs;
|
const {TabPane} = Tabs;
|
||||||
|
|
||||||
@ -730,4 +731,4 @@ class LoginPage extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LoginPage;
|
export default withTranslation()(LoginPage);
|
||||||
|
@ -23,6 +23,7 @@ import ja from "./locales/ja/data.json";
|
|||||||
import es from "./locales/es/data.json";
|
import es from "./locales/es/data.json";
|
||||||
import * as Conf from "./Conf";
|
import * as Conf from "./Conf";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
|
import {initReactI18next} from "react-i18next";
|
||||||
|
|
||||||
const resources = {
|
const resources = {
|
||||||
en: en,
|
en: en,
|
||||||
@ -80,7 +81,7 @@ function initLanguage() {
|
|||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
i18n.init({
|
i18n.use(initReactI18next).init({
|
||||||
lng: initLanguage(),
|
lng: initLanguage(),
|
||||||
|
|
||||||
resources: resources,
|
resources: resources,
|
||||||
|
Reference in New Issue
Block a user