Merge pull request #69 from shaohuihuang/qdu

解决iview和element-ui的国际化问题
This commit is contained in:
LiYang 2020-07-09 08:50:33 +08:00 committed by GitHub
commit 87b925563d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 12 deletions

8
package-lock.json generated
View File

@ -10861,9 +10861,9 @@
"integrity": "sha512-fUQhIVVfp2crf2wanLCpDLWp5Mao/i9lTQeS9Mj46/IOF+FuAKKyJ/ULk6+OlH0Ro6VEVGzlr/bQFArJdCfKsQ==", "integrity": "sha512-fUQhIVVfp2crf2wanLCpDLWp5Mao/i9lTQeS9Mj46/IOF+FuAKKyJ/ULk6+OlH0Ro6VEVGzlr/bQFArJdCfKsQ==",
"requires": { "requires": {
"marked": "^0.3.19", "marked": "^0.3.19",
"simple-hotkeys": "github:itargaryen/simple-hotkeys", "simple-hotkeys": "github:itargaryen/simple-hotkeys#8a6b2cf19d06100ac86d7ce4d442df08c561b7e9",
"simple-module": "github:itargaryen/simple-module#v2.1.0", "simple-module": "github:itargaryen/simple-module#ea2688c579170eca533cd0bd8ba7f83c8d241a1c",
"simple-uploader": "github:itargaryen/simple-uploader#v2.1.0", "simple-uploader": "github:itargaryen/simple-uploader#79d795ca1ce0b163c0e335fddad5bf9393004780",
"to-markdown": "^3.1.1" "to-markdown": "^3.1.1"
}, },
"dependencies": { "dependencies": {
@ -10888,7 +10888,7 @@
"from": "github:itargaryen/simple-uploader#v2.1.0", "from": "github:itargaryen/simple-uploader#v2.1.0",
"requires": { "requires": {
"jquery": "=3.1.1", "jquery": "=3.1.1",
"simple-module": "github:itargaryen/simple-module#v2.1.0" "simple-module": "github:itargaryen/simple-module#ea2688c579170eca533cd0bd8ba7f83c8d241a1c"
} }
} }
} }

View File

@ -1,12 +1,20 @@
import Vue from 'vue' import Vue from 'vue'
import VueI18n from 'vue-i18n' import VueI18n from 'vue-i18n'
// ivew UI
import ivenUS from 'iview/dist/locale/en-US'
import ivzhCN from 'iview/dist/locale/zh-CN'
import ivzhTW from 'iview/dist/locale/zh-TW'
// element UI
import elenUS from 'element-ui/lib/locale/lang/en'
import elzhCN from 'element-ui/lib/locale/lang/zh-CN'
import elzhTW from 'element-ui/lib/locale/lang/zh-TW'
Vue.use(VueI18n) Vue.use(VueI18n)
const languages = [ const languages = [
{value: 'en-US', label: 'English'}, {value: 'en-US', label: 'English', iv: ivenUS, el: elenUS},
{value: 'zh-CN', label: '简体中文'}, {value: 'zh-CN', label: '简体中文', iv: ivzhCN, el: elzhCN},
{value: 'zh-TW', label: '繁體中文'} {value: 'zh-TW', label: '繁體中文', iv: ivzhTW, el: elzhTW}
] ]
const messages = {} const messages = {}
@ -15,7 +23,8 @@ for (let lang of languages) {
let locale = lang.value let locale = lang.value
let m = require(`./oj/${locale}`).m let m = require(`./oj/${locale}`).m
Object.assign(m, require(`./admin/${locale}`).m) Object.assign(m, require(`./admin/${locale}`).m)
messages[locale] = {m: m} let ui = Object.assign(lang.iv, lang.el)
messages[locale] = Object.assign({m: m}, ui)
} }
// load language packages // load language packages
export default new VueI18n({ export default new VueI18n({

View File

@ -5,7 +5,6 @@ import store from '@/store'
import i18n from '@/i18n' import i18n from '@/i18n'
import Element from 'element-ui' import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en'
import filters from '@/utils/filters' import filters from '@/utils/filters'
import router from './router' import router from './router'
@ -28,7 +27,6 @@ Vue.use(VueAnalytics, {
id: GOOGLE_ANALYTICS_ID, id: GOOGLE_ANALYTICS_ID,
router router
}) })
Vue.use(Element, {locale})
Vue.use(katex) Vue.use(katex)
Vue.component(IconBtn.name, IconBtn) Vue.component(IconBtn.name, IconBtn)
Vue.component(Panel.name, Panel) Vue.component(Panel.name, Panel)

View File

@ -9,7 +9,6 @@ import VueAnalytics from 'vue-analytics'
import { GOOGLE_ANALYTICS_ID } from '@/utils/constants' import { GOOGLE_ANALYTICS_ID } from '@/utils/constants'
import iView from 'iview' import iView from 'iview'
import locale from 'iview/dist/locale/en-US'
import 'iview/dist/styles/iview.css' import 'iview/dist/styles/iview.css'
import Panel from '@oj/components/Panel.vue' import Panel from '@oj/components/Panel.vue'
@ -39,7 +38,9 @@ Object.keys(filters).forEach(key => {
}) })
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(iView, {locale}) Vue.use(iView, {
i18n: (key, value) => i18n.t(key, value)
})
Vue.use(VueClipboard) Vue.use(VueClipboard)
Vue.use(highlight) Vue.use(highlight)