多国语关联 element
Former-commit-id: 1618359119a731c527e611332d701a5914f5bb9f [formerly 9feccc1938ba071e992d6404c3006d10450a9832] [formerly 1618359119a731c527e611332d701a5914f5bb9f [formerly 9feccc1938ba071e992d6404c3006d10450a9832] [formerly 1618359119a731c527e611332d701a5914f5bb9f [formerly 9feccc1938ba071e992d6404c3006d10450a9832] [formerly 9feccc1938ba071e992d6404c3006d10450a9832 [formerly e3dc55c030d03beb36dd343c4871b1d84fd95872 [formerly 483f092cdca9e292945a8229077e36a0d3e41a3f]]]]] Former-commit-id: 743f99605b2d86ff42b9410d497dc7be08099db9 Former-commit-id: 0462f3977091d82973ad54e7364e680d96f3f083 Former-commit-id: fea191928cf858337b45f51a09e815d241954728 [formerly 9a3a49e14e57a522ab96f81d15ac36fec5aa117f] Former-commit-id: d7e12ab2a74e9e73fba2f8c119a8490ad8f6d0e6 Former-commit-id: 7376ec28b4d66367efc49efa6632be9914d8cc67 Former-commit-id: e14c86ae03d8a1cf6c1213343c4789d587c8a51f Former-commit-id: 3845f9903e2faa3b1179556754e5a41a16e84e18 Former-commit-id: 0ba0b7d8746895b07604fa5ba35301fcffc00bc3
This commit is contained in:
parent
6f426425c1
commit
9041b45660
|
|
@ -15,6 +15,31 @@
|
|||
<folder_node>
|
||||
<name></name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>_element</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>ja-JP</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>zh-CHS</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>zh-CHT</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>_name</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
|
|
|||
14
src/i18n.js
14
src/i18n.js
|
|
@ -7,13 +7,17 @@ Vue.use(VueI18n)
|
|||
function loadLocaleMessages () {
|
||||
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
|
||||
const messages = {}
|
||||
locales.keys().forEach(key => {
|
||||
for (const key of locales.keys()) {
|
||||
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
|
||||
if (matched && matched.length > 1) {
|
||||
const locale = matched[1]
|
||||
messages[locale] = locales(key)
|
||||
const localeElementUI = require(`element-ui/lib/locale/lang/${locales(key)._element}`)
|
||||
messages[locale] = {
|
||||
...locales(key),
|
||||
...localeElementUI ? localeElementUI.default : {}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return messages
|
||||
}
|
||||
|
||||
|
|
@ -24,8 +28,10 @@ Vue.prototype.$languages = Object.keys(messages).map(langlage => ({
|
|||
value: langlage
|
||||
}))
|
||||
|
||||
export default new VueI18n({
|
||||
const i18n = new VueI18n({
|
||||
locale: util.cookies.get('lang') || process.env.VUE_APP_I18N_LOCALE,
|
||||
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE,
|
||||
messages
|
||||
})
|
||||
|
||||
export default i18n
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"_element": "en",
|
||||
"_name": "English",
|
||||
"page": {
|
||||
"demo": {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"_element": "ja",
|
||||
"_name": "日本語",
|
||||
"page": {
|
||||
"demo": {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"_element": "zh-CN",
|
||||
"_name": "简体中文",
|
||||
"page": {
|
||||
"demo": {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"_element": "zh-TW",
|
||||
"_name": "繁體中文",
|
||||
"page": {
|
||||
"demo": {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import 'flex.css'
|
|||
import '@/components'
|
||||
// svg 图标
|
||||
import '@/assets/svg-icons'
|
||||
// 国际化
|
||||
import i18n from '@/i18n.js'
|
||||
|
||||
// 功能插件
|
||||
import pluginError from '@/plugin/error'
|
||||
|
|
@ -27,7 +29,9 @@ export default {
|
|||
// 构建时间
|
||||
Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
|
||||
// Element
|
||||
Vue.use(ElementUI)
|
||||
Vue.use(ElementUI, {
|
||||
i18n: (key, value) => i18n.t(key, value)
|
||||
})
|
||||
// 插件
|
||||
Vue.use(pluginError)
|
||||
Vue.use(pluginLog)
|
||||
|
|
|
|||
Loading…
Reference in New Issue