Vue Intl is the official FormatJS binding for Vue.js applications, providing comprehensive internationalization (i18n) and localization (l10n) capabilities. Currently at version 7.2.3, it is actively maintained as part of the broader FormatJS monorepo, which sees frequent updates across its packages. The library leverages web standards like the JavaScript `Intl` API, ECMA-402, Unicode CLDR, and ICU Message syntax for robust and accurate formatting of messages, dates, numbers, and more. It offers seamless integration with Vue 3's Composition API via `useIntl()` and also supports injection patterns, distinguishing itself by being part of a well-established, standards-compliant internationalization ecosystem with extensive tooling for message extraction and compilation.
npm install vue-intlVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to install `vue-intl`, configure it as a Vue plugin with messages, and use the `useIntl` Composition API hook for message formatting, alongside template-based formatters like `$formatDate` and `$formatMessage`.
Add a space inside the ICU MessageFormat's double curly braces, e.g., change `{{#}}` to `{ {#} }` or `{{ more}}` to `{ { more} }`.Dynamically import and register locale data for each language your application supports, for example, `import frLocaleData from 'vue-intl/locale-data/fr';`.
Conditionally load the necessary `Intl` polyfills based on browser support or include them directly in your build process for wider compatibility.
Ensure your build tooling (e.g., Babel, Webpack, Vite) is configured to transpile ES6 output if targeting older environments. Check FormatJS migration guides for specific packages if upgrading other FormatJS dependencies alongside `vue-intl`.
Utilize `@formatjs/cli`, `babel-plugin-formatjs`, or `@formatjs/ts-transformer` during your build process to pre-compile messages. This converts ICU strings into optimized JavaScript functions, improving performance and enabling advanced formatting.
Verify that the message `id` passed to `$formatMessage` or `intl.formatMessage` exists in your registered message dictionaries. Ensure that the correct locale messages are loaded and set for the application.