|
@@ -37,9 +37,9 @@ webpack.config.js
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-## Compatible with `vue-i18n`
|
|
|
+## Compatible with `vue-i18n@5.x`
|
|
|
|
|
|
-Element is compatible with [vue-i18n](https://github.com/kazupon/vue-i18n), which makes multilingual switching even easier.
|
|
|
+Element is compatible with [vue-i18n@5.x](https://github.com/kazupon/vue-i18n), which makes multilingual switching even easier.
|
|
|
|
|
|
```javascript
|
|
|
import Vue from 'vue'
|
|
@@ -56,7 +56,7 @@ Vue.locale('zh-cn', zhLocale)
|
|
|
Vue.locale('en', enLocale)
|
|
|
```
|
|
|
|
|
|
-## Compatibility with other i18n plugins
|
|
|
+## Compatible with other i18n plugins
|
|
|
Element may not be compatible with i18n plugins other than vue-i18n, but you can customize how Element processes i18n.
|
|
|
|
|
|
```javascript
|
|
@@ -72,6 +72,42 @@ Vue.use(Element, {
|
|
|
})
|
|
|
```
|
|
|
|
|
|
+## Compatible with `vue-i18n@6.x`
|
|
|
+
|
|
|
+You need to manually handle it for compatibility with `6.x`.
|
|
|
+
|
|
|
+```javascript
|
|
|
+import Vue from 'vue'
|
|
|
+import Element from 'element-ui'
|
|
|
+import VueI18n from 'vue-i18n'
|
|
|
+import enLocale from 'element-ui/lib/locale/lang/en'
|
|
|
+import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
|
|
|
+
|
|
|
+Vue.use(VueI18n)
|
|
|
+
|
|
|
+const messages = {
|
|
|
+ en: {
|
|
|
+ message: 'hello',
|
|
|
+ ...enLocale // Or use `Object.assign({ message: 'hello' }, enLocale)`
|
|
|
+ },
|
|
|
+ zh: {
|
|
|
+ message: '你好',
|
|
|
+ ...zhLocale // Or use `Object.assign({ message: '你好' }, zhLocale)`
|
|
|
+ }
|
|
|
+}
|
|
|
+// Create VueI18n instance with options
|
|
|
+const i18n = new VueI18n({
|
|
|
+ locale: 'en', // set locale
|
|
|
+ messages, // set locale messages
|
|
|
+})
|
|
|
+
|
|
|
+Vue.use(Element, {
|
|
|
+ i18n: key => i18n.vm._t(key)
|
|
|
+})
|
|
|
+
|
|
|
+new Vue({ i18n }).$mount('#app')
|
|
|
+```
|
|
|
+
|
|
|
## Import via CDN
|
|
|
|
|
|
```html
|