mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
Improve language code.
This commit is contained in:
@ -21,6 +21,7 @@ import i18next from "i18next";
|
||||
import copy from "copy-to-clipboard";
|
||||
import {authConfig} from "./auth/Auth";
|
||||
import {Helmet} from "react-helmet";
|
||||
import moment from "moment";
|
||||
|
||||
export let ServerUrl = "";
|
||||
|
||||
@ -308,20 +309,43 @@ export function getAvatarColor(s) {
|
||||
return colorList[random % 4];
|
||||
}
|
||||
|
||||
export function setLanguage() {
|
||||
let language = localStorage.getItem('language');
|
||||
if (language === undefined) {
|
||||
language = "en"
|
||||
}
|
||||
i18next.changeLanguage(language)
|
||||
export function setLanguage(language) {
|
||||
localStorage.setItem("language", language);
|
||||
changeMomentLanguage(language);
|
||||
i18next.changeLanguage(language);
|
||||
}
|
||||
|
||||
export function changeLanguage(language) {
|
||||
localStorage.setItem("language", language)
|
||||
i18next.changeLanguage(language)
|
||||
localStorage.setItem("language", language);
|
||||
changeMomentLanguage(language);
|
||||
i18next.changeLanguage(language);
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
export function changeMomentLanguage(language) {
|
||||
return;
|
||||
if (language === "zh") {
|
||||
moment.locale("zh", {
|
||||
relativeTime: {
|
||||
future: "%s内",
|
||||
past: "%s前",
|
||||
s: "几秒",
|
||||
ss: "%d秒",
|
||||
m: "1分钟",
|
||||
mm: "%d分钟",
|
||||
h: "1小时",
|
||||
hh: "%d小时",
|
||||
d: "1天",
|
||||
dd: "%d天",
|
||||
M: "1个月",
|
||||
MM: "%d个月",
|
||||
y: "1年",
|
||||
yy: "%d年",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function getClickable(text) {
|
||||
return (
|
||||
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
||||
|
Reference in New Issue
Block a user