Vue I18n is the official and widely adopted internationalization plugin for Vue.js, providing comprehensive features to localize Vue 3 applications. The current stable version is 11.3.2, with the project maintaining an active and frequent release cadence focused on bug fixes and incremental feature enhancements, as evidenced by its recent rapid succession of patch releases. Key differentiators include its deep and seamless integration with Vue's reactivity system, support for both the Options API and Composition API, sophisticated pluralization rules, robust date and number formatting capabilities, and a flexible message syntax that handles interpolation, linked messages, and even HTML content. It provides various optimized build artifacts (e.g., global, esm-browser, esm-bundler, cjs, node.mjs) to cater to diverse deployment environments, from direct CDN usage in browsers to modern bundler-driven setups and server-side rendering with Node.js. It's built on the Intlify project, ensuring a consistent and performant i18n experience for the Vue ecosystem.
npm install vue-i18nVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the setup of Vue I18n with Vue 3's Composition API, including creating an i18n instance, defining messages, using the `t` function for translations, and dynamically changing the locale.
Migrate your application to Vue 3, then follow the official Vue I18n v9+ migration guide to adapt your i18n configuration and usage to the new API. This often includes setting `legacy: false` in `createI18n` for Composition API usage.
If you need to compile messages in the browser at runtime (e.g., from inline JavaScript strings), use the full build (e.g., `vue-i18n.esm-bundler.js`). Otherwise, ensure all locale messages are pre-compiled during your build process (e.g., by using JSON files for messages).
Refactor your Node.js server-side rendering or build scripts to use ES Module `import` statements and the `vue-i18n.node.mjs` entry point instead of CommonJS `require`.
Ensure your bundler is configured to replace these feature flags with appropriate boolean values (e.g., `true` or `false`). Consult the Vue I18n documentation or your bundler's configuration guide for details on how to set these global defines.
Verify that your `messages` object contains entries for all active and fallback locales, and that they are correctly structured and passed into the `createI18n` function.
For Options API, ensure `app.use(i18n)` is called in your main application entry point. For Composition API, ensure `const { t } = useI18n()` is called within a component's `setup` function or a setup-like context, and that `legacy: false` is set in `createI18n`.When initializing your i18n instance with `createI18n`, explicitly include `legacy: false` in the options object to enable Composition API support: `createI18n({ legacy: false, ... })`.