icon i18n
This commit is contained in:
@@ -4,6 +4,7 @@ const en = {
|
||||
},
|
||||
content: {
|
||||
blankTip: "I am Blank.",
|
||||
noteTip: "Start writing something...",
|
||||
},
|
||||
button: {
|
||||
ok: "OK",
|
||||
|
||||
@@ -3,7 +3,8 @@ const zh = {
|
||||
askTodelete: "是否确定要删除?",
|
||||
},
|
||||
content: {
|
||||
blankTip: "I am Blank.",
|
||||
blankTip: "空白的内容。",
|
||||
noteTip: "开始写下一些东西吧。。。"
|
||||
},
|
||||
button: {
|
||||
ok: "好的",
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user