Skip to content

Reference

Architecture

vue-i18n-kit

├── plugin.ts
│     createVueI18nPlugin() — installs vue-i18n, pre-loads defaultLocale/fallbackLocale,
│     stores I18nService via app.provide(); returns Plugin & { service }

├── state.ts
│     Per-app state via provide/inject — locale Ref, isLoading Ref, availableLocales,
│     subscribers list, messages cache; SSR-safe (no module-level singletons)

├── composables/
│     useLocale()           — locale, setLocale, isLoading, localeMeta
│     useT()                — t() key lookup + interpolation; tm() ICU pluralization
│     useAvailableLocales() — computed list of { code, meta } from registered locales
│     useFormat()           — formatDate / formatNumber / formatCurrency via Intl
│     usePluralize()        — Intl.PluralRules engine powering tm(); exports pluralCategory()

├── utils/
│     loadLocale.ts    — resolves sync objects and async loaders; caches by locale code
│     persistLocale.ts — localStorage read / write helpers (try/catch for SSR/private mode)
│     localeKeys.ts    — flattenKeys, compareLocales (shared by CLI + Vite plugin)
│     localeEntry.ts   — isLocaleDefinition, extractMessages, extractMeta

├── vite-plugin/
│     vueI18nCheckPlugin     — buildStart + HMR key-diff against reference locale
│     vueI18nInlinePlugin    — virtual:vue-i18n-kit/locales (bakes JSON into bundle)
│     vueI18nNamespacePlugin — virtual:vue-i18n-namespaces (per-namespace dynamic imports)
│     vueI18nDevPlugin       — SFC template rewrite (auto-wrap); injects I18nInspect overlay
│     vueI18nMapPlugin       — locales map for the editor server (written by auto-config)

├── ui-app/               — Locale editor Vue SPA (built to dist/ui-server/public/)
│     App.vue, LocaleTable.vue, Dashboard.vue, api.ts

├── ui-server/
│     server.ts           — Node.js HTTP server; reads/writes locale JSON; SSE for live reload

└── cli/
      init / add / check / merge / prune / types / split / merge-ns
      stale / export / import / stats / auto-config / ui / dev

Bundle size & peer dependencies

Entry pointPeer depsNotes
vue-i18n-kitvue ^3.3, vue-i18n ^9.0Runtime composables and plugin — for Vue apps
vue-i18n-kit/vitevue ^3.3, vite >=5.0 (optional)Vite plugins — for vite.config.ts
vue-i18n-kit (bin)CLI — init, add, check, ui, dev, and more

The package ships as tree-shakeable ESM (dist/index.mjs) and CommonJS (dist/index.cjs). Composables that are not used are tree-shaken away. The Vite plugins and CLI are not included in the browser bundle.

Development

bash
# Install dependencies
npm install

# Build (ESM + CJS + type declarations)
npm run build

# Run tests
npm test

# Watch mode
npm run test:watch

# Type check
npm run typecheck

Tests are written with Vitest and @vue/test-utils. The test suite covers the plugin, all composables, the ICU engine, locale key utilities, and the LocaleEntry disambiguation logic.

License

MIT