A Vite plugin for internationalization (i18n) that integrates seamlessly with Vite's build process. Version 1.0.2 provides a simple way to manage translation files, auto-generate type-safe i18n functions, and optimize bundle size by tree-shaking unused translations. It supports JSON, YAML, and TypeScript translation files with hot-reload in development. Compared to alternatives like i18next or vue-i18n, it offers a lower overhead and tighter Vite integration. Release cadence is irregular with limited community adoption.
npm install vite-plugin-i18nVerified import paths — ran on the pinned version, not inferred.
Configures the plugin in vite.config.ts, then defines and uses i18n functions in a component.
Check compatibility with your Vite version; consider using an alternative like @intlify/vite-plugin-vue-i18n for newer Vite.
Use 'localesDir' instead of 'messagesDir'.
Set 'typesOutput' to a file path to enable auto-generated types.
Save locale files as UTF-8 with BOM or use Unicode escape sequences.
Run 'npm install vite-plugin-i18n' and ensure 'tsconfig.json' includes 'node_modules/@types'.
Change 'const i18nPlugin = require(...)' to 'import i18nPlugin from ...'.
Check that 'locales' array and 'defaultLocale' are provided in plugin options.