One, [email protected] Installation
Ii. introduction of [email protected]
1 import vuei18n from ' vue-i18n '2 vue.use (vuei18n)
Third, introduced the use of the Component language Pack (for example: Elementui)
1 import enlocale from ' element-ui/lib/locale/lang/en '2 import Zhlocale from ' element-ui/lib/locale/ LANG/ZH-CN '3 import elementlocale from ' Element-ui/lib/locale '
Iv. creating a custom language pack, merging with the component language pack
1 Const messages = { 2 en: { 3 message: ' Hello ', 4
. enlocale 5 }, 6 zh: { 7 message: ' Hello ', 8... zhlocale 9 }10 }
V. Creation of VUEI18N instance
1 New vuei18n ({2 // set locale3 // set locale messages 4 })
Vi. Elementui using customized i18n unified management
1 elementlocale.i18n (key, value) = I18N.T (key, value))
Vii. Use of
Self-defined message
Locale: ' en ', shown as Hello
Locale: ' zh ', shown as Hello
Language packs in the Elementui
Locale: ' en ', shown as Select
Locale: ' zh ', show as Please select
There are errors and mistakes welcome advice ~ ~
VUE+WEBPACK+NPM in multi-lingual projects [email protected]