petite-vue-i18n is a specialized, lightweight internationalization library for Vue 3 applications, offering a trimmed-down feature set compared to the full vue-i18n package. Currently at version 11.3.2, it maintains a regular release cadence with frequent bug fixes and minor improvements, often in sync with the main vue-i18n project. Its primary differentiation lies in its significantly smaller bundle size (up to 45% smaller for runtime-only builds) by exclusively supporting the Composition API and focusing solely on core translation capabilities. It omits features like date/number formatting ($n, $d), rich text rendering ($rt), hierarchical message handling out-of-the-box, the v-t directive, and components like i18n-t, making it ideal for projects where only basic text translation is required and bundle size is critical. Migration to the full vue-i18n is designed to be seamless if more features become necessary later.
npm install petite-vue-i18nVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up `petite-vue-i18n` with `createI18n`, use the `useI18n` hook for translations (`t`), and dynamically switch locales in a Vue 3 application.
Migrate all i18n logic to use the Composition API's `useI18n()` hook, typically within a component's `setup` function or `<script setup>` block.
Remove `v-t` directives. Translations in templates must be performed using interpolation, e.g., `{{ t('your.key') }}` after exposing `t` from `useI18n()`.Remove all calls to `$d`, `d`, `$n`, or `n`. If date/number formatting is required, you must migrate to the full `vue-i18n` package or implement custom formatting logic.
Restructure your locale messages to be flat (e.g., `auth_login: '...'`) or implement a custom message resolver function when creating the i18n instance.
Be aware of the strict array-order fallback. Ensure your `fallbackLocale` array reflects the precise fallback order desired.
Remove all references to `$n` or `n`. petite-vue-i18n is translation-only. Use full vue-i18n if number formatting is needed.
Replace `v-t` directives with template interpolations like `{{ t('your.key') }}` after exposing `t` from `useI18n()` in your component's setup function.Either flatten your locale messages (e.g., `auth_login: '...'`) or provide a custom message resolver function during `createI18n` initialization.
Ensure you have `import { createApp } from 'vue'` and that `createApp()` is called to initialize your `app` constant before `app.use(i18n)`.