The `vue-cli-plugin-i18n` package is a Vue CLI plugin designed to integrate `vue-i18n` into new or existing Vue projects, streamlining the setup of internationalization. As of version 2.3.2, its latest release in late 2021, the plugin provides scaffolding for `vue-i18n`'s basic configuration, support for locale messages within Single File Components via `vue-i18n-loader`, and experimental reporting features for missing or unused locale keys. It supports both Vue 2 and Vue 3 projects, offering distinct options like `enableInSFC` for Vue 2 (related to `vue-i18n` v8.x) and `enableLegacy` or `runtimeOnly` for Vue 3 (related to `vue-i18n` v9+). Additionally, it includes a `enableBridge` option for Vue 2 projects to facilitate migration to `vue-i18n@v9.x`. The plugin is maintained by the Intlify organization, known for the `vue-i18n` library itself, ensuring close compatibility and up-to-date best practices.
npm install vue-cli-plugin-i18nVerified import paths — ran on the pinned version, not inferred.
This demonstrates how to create a new Vue project, add the i18n plugin, and integrate the scaffolded internationalization setup into the main application entry point.
Set `enableLegacy: true` in `vue.config.js` under `pluginOptions.i18n` for legacy API or refactor i18n usage to `createI18n` and `useI18n` with Vue I18n v9+.
Run `npm install @vue/composition-api` or `yarn add @vue/composition-api` in your project if you enable `enableBridge` and use the Composition API.
Ensure your project is Vue 2 and using vue-i18n v8.x when setting `enableInSFC: true` in `vue.config.js`.
Be aware of this limitation; manual review may be necessary for locale messages within custom blocks.
For new Vue 3 projects, consider directly integrating `vue-i18n` using Vite or similar build tools without the CLI plugin, or explore `@intlify/vue-i18n-unplugin` for Vite/Webpack integration.
Ensure `runtimeOnly: false` (or omit) if you need the full build, or `runtimeOnly: true` if you intend to use the runtime-only version, configured in `vue.config.js` under `pluginOptions.i18n`.
Verify that `app.use(i18n)` is called in your `main.js` (or `main.ts`) file after creating the Vue app, and that `i18n` is correctly imported from the generated `src/i18n.js`.
Ensure that a locale messages file (e.g., `en.json`) exists in your `localeDir` and contains valid internationalization messages for the `fallbackLocale`.