icon i18n

This commit is contained in:
Jesse-Ma
2022-12-02 17:58:20 +08:00
parent 49916b166e
commit 7fb00c8cf5
13 changed files with 24 additions and 144 deletions

View File

@@ -5,20 +5,26 @@ Vue.use(VueI18n);
import zh from "./config/zh";
import en from "./config/en";
const messages = {
zh,
en,
}
const i18n = new VueI18n({
messages: messages,
locale: getLocale(),
messages: {
zh,
en,
},
});
function getLocale(){
if(localStorage.getItem("locale")){
return localStorage.getItem("locale").substring(0,2);
}
function getLocale() {
var lang = navigator.language;
if (lang) {
lang = lang.substring(0, 2);
}
return "en";
if (Object.keys(messages).indexOf(lang) >= 0) {
return lang;
}
return "en";
}
export default i18n;