|
@@ -108,6 +108,39 @@ Vue.use(Element, {
|
|
|
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
|
|
|
|
|
|
```html
|