mirror of https://github.com/ElemeFE/element
Docs(i18n): add on-demand
parent
99f9d995da
commit
78bea12568
|
@ -108,6 +108,39 @@ Vue.use(Element, {
|
||||||
new Vue({ i18n }).$mount('#app')
|
new Vue({ i18n }).$mount('#app')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Custom i18n in on-demand components
|
||||||
|
|
||||||
|
```js
|
||||||
|
import Vue from 'vue'
|
||||||
|
import DatePicker from 'element/lib/date-picker'
|
||||||
|
import VueI18n from 'vue-i18n'
|
||||||
|
|
||||||
|
import enLocale from 'element-ui/lib/locale/lang/en'
|
||||||
|
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
|
||||||
|
import ElementLocale from 'element-ui/lib/locale'
|
||||||
|
|
||||||
|
Vue.use(VueI18n)
|
||||||
|
Vue.use(DatePicker)
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
en: {
|
||||||
|
message: 'hello',
|
||||||
|
...enLocale
|
||||||
|
},
|
||||||
|
zh: {
|
||||||
|
message: '你好',
|
||||||
|
...zhLocale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Create VueI18n instance with options
|
||||||
|
const i18n = new VueI18n({
|
||||||
|
locale: 'en', // set locale
|
||||||
|
messages, // set locale messages
|
||||||
|
})
|
||||||
|
|
||||||
|
ElementLocale.i18n(key => i18n.t(key))
|
||||||
|
```
|
||||||
|
|
||||||
## Import via CDN
|
## Import via CDN
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
|
|
@ -120,6 +120,39 @@ Vue.use(Element, {
|
||||||
new Vue({ i18n }).$mount('#app')
|
new Vue({ i18n }).$mount('#app')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 按需加载里定制 i18n
|
||||||
|
|
||||||
|
```js
|
||||||
|
import Vue from 'vue'
|
||||||
|
import DatePicker from 'element/lib/date-picker'
|
||||||
|
import VueI18n from 'vue-i18n'
|
||||||
|
|
||||||
|
import enLocale from 'element-ui/lib/locale/lang/en'
|
||||||
|
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
|
||||||
|
import ElementLocale from 'element-ui/lib/locale'
|
||||||
|
|
||||||
|
Vue.use(VueI18n)
|
||||||
|
Vue.use(DatePicker)
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
en: {
|
||||||
|
message: 'hello',
|
||||||
|
...enLocale
|
||||||
|
},
|
||||||
|
zh: {
|
||||||
|
message: '你好',
|
||||||
|
...zhLocale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Create VueI18n instance with options
|
||||||
|
const i18n = new VueI18n({
|
||||||
|
locale: 'en', // set locale
|
||||||
|
messages, // set locale messages
|
||||||
|
})
|
||||||
|
|
||||||
|
ElementLocale.i18n(key => i18n.t(key))
|
||||||
|
```
|
||||||
|
|
||||||
## 通过 CDN 的方式加载语言文件
|
## 通过 CDN 的方式加载语言文件
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
|
Loading…
Reference in New Issue