Skip to content

CLI — Scaffolding & Codegen

The vue-i18n-kit CLI helps scaffold and audit locale JSON files.

bash
# Via npx (no install needed)
npx vue-i18n-kit <command> [options]

# Or after installing the package
vue-i18n-kit <command> [options]

This page covers the scaffolding and generation commands — init, add, merge, types, split, merge-ns. For the audit and reporting commands (check, prune, stale, export, import, stats), see CLI — Audit & Reports.

init — Interactive setup wizard

Launches an interactive wizard that scaffolds the entire localization setup.

bash
vue-i18n-kit init

What it does:

  1. Auto-scans the project for an existing createVueI18nPlugin call and pre-fills locale codes as defaults.
  2. Prompts for locale codes, display names, and flag emojis.
  3. Prompts for the locales directory and toolkit directory paths.
  4. Detects vite.config.ts / nuxt.config.ts and optionally adds vueI18nMapPlugin automatically.
  5. Handles existing locale JSON files — keep, overwrite, or copy structure from another locale.
  6. Writes i18n-kit.config.json, i18n-tools/locales.config.json, locale JSON stubs.

Running vue-i18n-kit init on an existing project offers three choices: use the current config as-is, update settings, or reinitialize from scratch.

i18n Ally integration — the wizard optionally generates .vscode/settings.json for i18n Ally with inline translation previews and missing-key highlighting.

add — Add a new locale

Copies the structure of an existing locale file into a new one.

bash
vue-i18n-kit add fr
vue-i18n-kit add fr --from en --empty
vue-i18n-kit add de --dir src/i18n --from en --empty
FlagDefaultDescription
--dir <path>src/localesLocales directory.
--from <locale>first file in dirSource locale to copy structure from.
--emptyfalseWrite empty strings instead of copying source values.

merge — Merge a shared dictionary

Deep-merges a base or corporate JSON dictionary into project locale files. Only adds missing keys by default — existing translations are left untouched unless --overwrite is passed.

bash
vue-i18n-kit merge shared/base.json --dry
vue-i18n-kit merge shared/base.json
vue-i18n-kit merge updates.json --locale ru --overwrite
FlagDefaultDescription
--dir <path>src/localesLocales directory.
--locale <code>all localesOnly merge into this locale code.
--overwritefalseOverwrite existing keys instead of skipping them.
--dryfalsePreview changes without writing any files.
--no-sortfalseSkip alphabetical sort of result keys.

Keys listed in ignore.prune and locked in i18n-kit.config.json are never overwritten — even with --overwrite.

types — Generate TypeScript types

Generates a TranslationKey union type from a reference locale file. Gives you autocomplete and compile-time key checking when calling t().

bash
vue-i18n-kit types
vue-i18n-kit types --out src/types/i18n.d.ts --locale en --watch
FlagDefaultDescription
--out <path>src/i18n.d.tsOutput file path.
--locale <code>first in configLocale to use as the key source.
--dir <path>src/localesLocales directory.
--watchfalseRegenerate automatically when the locale file changes.

Generated file example:

ts
// src/i18n.d.ts — generated by vue-i18n-kit, do not edit

export type TranslationKey = 'buttons.cancel' | 'buttons.submit' | 'greeting' | 'items'

declare module 'vue-i18n-kit' {
  interface Register {
    key: TranslationKey
  }
}

With the Register augmentation the compiler will error on unknown keys:

ts
const { t } = useT()
t('buttons.submit') // ✓
t('buttons.submitt') // ✗ TypeScript error

split — Split a monolithic locale into namespaces

Splits each {locale}.json into per-namespace files: {locale}/{namespace}.json.

bash
vue-i18n-kit split
vue-i18n-kit split --dir src/locales --out src/locales/split --dry
FlagDefaultDescription
--dir <path>localesDir from configSource locales directory.
--out <path><dir>/splitOutput directory.
--dryfalsePreview without writing files.

merge-ns — Merge namespace files back into flat JSON

Reverse operation of split: reads all *.json files in each locale subdirectory and merges them into a single {locale}.json.

bash
vue-i18n-kit merge-ns
vue-i18n-kit merge-ns --dir src/locales/split --out src/locales --dry