Skip to content

Reference ​

Architecture ​

vue-i18n-kit
│
├── plugin.ts
│     createVueI18nPlugin() — installs vue-i18n (via createI18n.ts), pre-loads
│     defaultLocale/fallbackLocale, stores I18nService via app.provide();
│     returns Plugin & { service }
│
├── createI18n.ts
│     Internal wrapper around vue-i18n's own createI18n() — not a public export
│
├── state.ts
│     Per-app state via provide/inject — locale Ref, isLoading Ref, availableLocales,
│     subscribers list, messages cache; SSR-safe (no module-level singletons)
│
├── config/
│     schema.ts — I18nKitConfig, I18nKitRules, I18nKitIgnore, LocaleConfig, LocaleMeta
│     index.ts  — findConfigPath / readConfig / writeConfig (Node-only; used by the
│                   CLI and editor server, not part of the browser bundle)
│
├── 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()
│     useNamespace()        — lazy-loads namespace(s) for the active locale, SSR-aware
│
├── 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
│     scanner.ts       — source-file scanning for t()/tm()/$t() usage (CLI + editor)
│     sort.ts          — alphabetical key sorting shared by merge/split/merge-ns
│
├── 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 dev-overlay/ bundle
│     vueI18nMapPlugin       — locales map for the editor server (written by init/auto-config)
│
│     dev-overlay/ (pre-built, injected at dev-time by vueI18nDevPlugin)
│         DevOverlay.vue, I18nInspect.vue — floating editor overlay + inspect popup
│         directive.ts  — v-i18n-inspect
│         eventBus.ts   — overlay ↔ host-app message bus
│
├── 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 / dev / ui / auto-config / add / check / merge / prune / types
      split / merge-ns / stale / export / import / stats

Bundle size & peer dependencies ​

Entry pointPeer depsNotes
vue-i18n-kitvue ^3.3, vue-i18n ^11.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/config—Types-only: I18nKitConfig, LocaleConfig, LocaleMeta, I18nKitRules, I18nKitIgnore
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.js). 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