Vue CLI plugin to add vue-i18n to your Vue Project
If yon don't have a project created with Vue CLI:
vue create my-vue-app
Install the plugin into your project:
cd my-vue-app
vue add i18n
vue-cli-service i18n:report (experimental)Report the missing locale message keys and unused keys.
NOTE: limitation
vue-cli-service i18n:reportcannot detect missing and unused keys from local messages of i18n custom blocks.
When vue-i18n code files had been scaffolded into your project, the following env variables generate into .env:
VUE_APP_I18N_LOCALEThe locale of project localization, default en.
VUE_APP_I18N_FALLBACK_LOCALEThe locale of project fallback localization, default en.
These env variables are read in src/i18n.(js|ts).
vue-cli-plugin-i18n have some plugin options in vue.config.js:
module.exports = {
pluginOptions: {
i18n: {
locale: 'ja',
fallbackLocale: 'en',
localeDir: 'locales',
enableInSFC: false,
enableLegacy: false
}
}
}
localestringenThe locale of project localization.
fallbackLocalestringenThe fallback locale of project localization.
localeDirstringlocalesThe directory where store localization messages of project. The specified directory will start from the src directory.
enableInSFCbooleanfalseWhether enable locale messages in Single file components. Default No in prompt, for Vue 2 and Vue I18n v8.x only.
enableLegacybooleanfalseWhether use legacy mode API in Vue I18n. Default No in prompt, for Vue 3 and Vue I18n v9 or later.
enableBridgebooleanfalseWhether to set up a bridge to migrate to vue-i18n@v9.x from vue-i18n@v8.26, Default No in prompt.
> ⚠️ NOTE: If you use the Composition API with vue-i18n-bridge in bridge mode, you need to install @vue/composition-api.
includeLocalesbooleanfalseWhen enableBridge is true, i.e. in bridge mode, whether localization messages placed in localeDir option should be pre-compiled by message compiler or not.
If you use Composition API in bridge mode, this option must be true because all localization messages are bundled during production build.
runtimeOnlybooleanfalseWhether or not to use Vue I18n runtime-only, set in the vue-i18n field of webpack resolve.alias option. default Vue I18n (vue-i18n) package.json module field will be used.
If true is specified, Vue I18n (vue-i18n) will use node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js.
For more details, See here
compositionOnlybooleanenableLegacy set false, true else then falseWhether to make vue-i18n's API only composition API. By default the legacy API is tree-shaken.
For more details, See here
fullInstallbooleantrueWhether to install the full set of APIs, components, etc. provided by Vue I18n. By default, all of them will be installed.
If false is specified, build-in components and directive will not be installed in vue and will be tree-shaken.
For more details, See here
Details changes for each release are documented in the CHANGELOG.md.
Please make sure to read the Issue Reporting Checklist before opening an issue. Issues not conforming to the guidelines may be closed immediately.
Managed with GitHub Projects
Please make sure to read the Contributing Guide before making a pull request.