diff --git a/web/src/App.js b/web/src/App.js
index ad2973ea..d18d9725 100644
--- a/web/src/App.js
+++ b/web/src/App.js
@@ -72,7 +72,6 @@ class App extends Component {
}
UNSAFE_componentWillMount() {
- Setting.setLanguage();
this.updateMenuKey();
this.getAccount();
}
@@ -139,6 +138,13 @@ class App extends Component {
return location.toString().replace(location.search, "");
}
+ setLanguage(account) {
+ let language = account?.language;
+ if (language !== "" && language !== i18next.language) {
+ Setting.setLanguage(language);
+ }
+ }
+
getAccount() {
let query = this.getAccessTokenParam();
if (query === "") {
@@ -153,6 +159,8 @@ class App extends Component {
if (res.status === "ok") {
account = res.data;
account.organization = res.data2;
+
+ this.setLanguage(account);
} else {
if (res.msg !== "Please sign in first") {
Setting.showMessage("error", `Failed to sign in: ${res.msg}`);
@@ -196,7 +204,7 @@ class App extends Component {
handleRightDropdownClick(e) {
if (e.key === '/account') {
this.props.history.push(`/account`);
- } else if (e.key === 'logout') {
+ } else if (e.key === '/logout') {
this.logout();
}
}
diff --git a/web/src/common/Conf.js b/web/src/Conf.js
similarity index 78%
rename from web/src/common/Conf.js
rename to web/src/Conf.js
index 2c3b38b7..b226f0cc 100644
--- a/web/src/common/Conf.js
+++ b/web/src/Conf.js
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-export const ShowGithubCorner = false
+export const ShowGithubCorner = false;
+export const GithubRepo = "https://github.com/casbin/casdoor";
-export const GithubRepo = "https://github.com/casbin/casdoor"
+export const ForceLanguage = "en";
+export const DefaultLanguage = "en";
diff --git a/web/src/CustomGithubCorner.js b/web/src/CustomGithubCorner.js
index 06d8c0c2..6b161bbc 100644
--- a/web/src/CustomGithubCorner.js
+++ b/web/src/CustomGithubCorner.js
@@ -13,7 +13,7 @@
// limitations under the License.
import React from "react";
-import * as Conf from "./common/Conf"
+import * as Conf from "./Conf";
import GithubCorner from "react-github-corner";
class CustomGithubCorner extends React.Component {
diff --git a/web/src/SelectLanguageBox.js b/web/src/SelectLanguageBox.js
index 7642dfe8..50ab17c8 100644
--- a/web/src/SelectLanguageBox.js
+++ b/web/src/SelectLanguageBox.js
@@ -30,13 +30,11 @@ class SelectLanguageBox extends React.Component {
};
}
- onClick(e) {
- Setting.changeLanguage(e.key);
- };
-
render() {
const menu = (
-