Multilingual vue-i18n@8.x in the VUE+WEBPACK+NPM project

Source: Internet
Author: User
Tags i18n locale

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

    • {{$t (message)}}:
Self-defined message
Locale: ' en ', shown as Hello
Locale: ' zh ', shown as Hello



    • El.select.placeholder:
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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.