This commit is contained in:
saplf
2018-09-29 21:33:23 +08:00
parent 0a2c4e30de
commit be7755c0f3
40 changed files with 936 additions and 73 deletions

15
src/i18n/en.js Normal file
View File

@@ -0,0 +1,15 @@
export default {
login: {
title: 'TIC Node Console',
inputLabel: '请输入密语例如Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos, molestias, quisquam?',
loginBtn: 'Sign in',
errorMnemonic: 'Invalid secret word',
},
home: {
titleOwner: 'Owner',
titleChain: 'Chain',
titleNode: 'Node',
titleNetwork: 'Network',
titleMarket: 'Market',
},
}

39
src/i18n/index.js Normal file
View File

@@ -0,0 +1,39 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import { storage } from '../services'
import en from './en'
import axios from 'axios'
Vue.use(VueI18n)
const loadedLanguages = [ 'en' ]
export const i18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages: { en },
})
function setI18nLanguage(lang) {
i18n.locale = lang
axios.defaults.headers.common['Accept-Language'] = lang
document.querySelector('html').setAttribute('lang', lang)
storage.currentLanguage = lang
return lang
}
export async function loadLanguageAsync(lang) {
// noinspection JSIgnoredPromiseFromCall
if (i18n.locale !== lang) {
if (!loadedLanguages.includes(lang)) {
const langRes = await import(`@/i18n/${lang}`)
loadedLanguages.push(lang)
i18n.setLocaleMessage(lang, langRes.default)
return setI18nLanguage(lang)
}
return setI18nLanguage(lang)
}
return lang
}
loadLanguageAsync(storage.currentLanguage)

15
src/i18n/zh-CN.js Normal file
View File

@@ -0,0 +1,15 @@
export default {
login: {
title: 'TIC Node 节点控制台',
inputLabel: '请输入密语例如Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos, molestias, quisquam?',
loginBtn: '登录',
errorMnemonic: '输入的密语无效',
},
home: {
titleOwner: '个人中心',
titleChain: '区块/交易',
titleNode: '当前节点',
titleNetwork: '网络链接',
titleMarket: '应用商城',
},
}