Internationalization plugin for Vue.js
$ npm install vue-i18n
Internationalization plugin for Vue.js
The current codebase has most of the existing features on Vue I18n v8.x and is usable.
Since the library is still unstable and because we want feedback on bugs and missing features, it will probably go through a few breaking changes.
If you use stable Vue I18n version, see this repository
New style API for Vue 3. See the following docs:
<i18n-t> Component (formerly called <i18n> component)You can use pluralization on the component. See the blow examples:
<i18n-d> ComponentYou can use datetime format on the component, like <i18n-n> component.
See the below examples:
See the examples directory.
The examples are offered that use the following two API styles:
$t and t methods is string only. object and array values are no longer returned.
$tm / tm$tc and tc methods is string only. object and array values are no longer returned.
$tm / tmVueI18n class cannot used with new. It can only be used via the $i18n property of Vue instance.
new VueI18n with createI18n, you can use existing VueI18n options as they are.examples/legacy directory.VueI18n.prototype.getChoiceIndex
pluralizationRules option of createI18n factory function (like new VueI18n(...))pluralRules option of createI18nComposer factory functionwarnHtmlInMessage option:
warnHtmlMessage boolean property, default true.warnHtmlInMessage property.sync option:
false from truev-t directive
preserve modifier deprecated, keep Element contentpreserveDirectiveContent option, and property deprecatedVueI18n.version -> import { VERSION } from 'vue-i18n'VueI18n.availabilities -> import { availabilities } from 'vue-i18n'<i18n> component
<i18n-t> componentBoolean type from tag proptag prop is not specified, return the Fragmentplace propplaces proppath prop (Rename to keypath prop)<i18n-n> component
Boolean type from tag proptag prop is not specified, return the FragmentStatus: Ready@intlify/devtoolsvue-cli-plugin-i18n@intlify/eslint-plugin-vue-i18nnpm install --save vue-i18n@next
yarn add vue-i18n@next
vue-i18n.global(.prod).js:
<script src="..."> in the browser. Exposes the VueI18n global.<script src="...">.*.prod.js files for production.vue-i18n.esm-browser(.prod).js:
<script type="module">.vue-i18n.esm-bundler.js:
webpack, rollup and parcel.process.env.NODE_ENV guards (must be replaced by bundler)Starting with 9.0.0-beta.2, esm-bundler builds now exposes global feature flags that can be overwritten at compile time:
__VUE_I18N_FULL_INSTALL__ (enable/disable, in addition to vue-i18n APIs, components and directives all fully support installation: true)__VUE_I18N_LEGACY_API__ (enable/disable vue-i18n legacy style APIs support, default: true)__INTLIFY_PROD_DEVTOOLS__ (enable/disable intlify-devtools and vue-devtools support in production, default: false)The build will work without configuring these flags, however it is strongly recommended to properly configure them in order to get proper tree-shaking in the final bundle. To configure these flags:
define optionNote: the replacement value must be boolean literals and cannot be strings, otherwise the bundler/minifier will not be able to properly evaluate the conditions.
args typingLocaleMessages / LocaleMessage / LocaleMessageDictiory<i18n-t><i18n-n><i18n-d>v-t© 2010 - cnpmjs.org x YWFE | Home | YWFE