Skip to content

API Reference ​

Runtime types ​

All public types are re-exported for use in consumer projects:

ts
import type {
  // Plugin
  I18nPluginOptions,
  I18nPlugin, // return type of createVueI18nPlugin — Plugin & { service }
  I18nService, // { locale, isLoading, setLocale, availableLocales, onLocaleChange, loadNamespace, isNamespaceLoaded }

  // Locale entry types
  LocaleMessages, // Record<string, unknown>
  LocaleEntry, // LocaleMessages | LocaleLoader | LocaleDefinition
  LocaleDefinition, // { messages, meta? }
  LocaleInfo, // { code, meta } — returned by useAvailableLocales

  // Composable return shapes
  UseLocaleReturn,
  UseTReturn,
  UseAvailableLocalesReturn,
  UseFormatReturn,
  UsePluralizeReturn,
  UseNamespaceReturn,

  // Pluralization
  PluralVars, // Record<string, string | number>
} from 'vue-i18n-kit'

See Plugin Setup, Plugin Service, and the Composables pages for what each shape actually contains.

Typing locale metadata ​

Define a project-wide interface for your meta shape and pass it as a generic to both composables:

ts
// types/i18n.ts
export interface AppLocaleMeta {
  display: string // human-readable locale name
  flag?: string // emoji flag, optional
  author?: string // translator credit, optional
}
ts
import type { AppLocaleMeta } from '@/types/i18n'
import { useLocale, useAvailableLocales } from 'vue-i18n-kit'

const { localeMeta } = useLocale<AppLocaleMeta>()
localeMeta.value?.display // string | undefined  ✓

const { availableLocales } = useAvailableLocales<AppLocaleMeta>()
availableLocales.value[0].meta?.flag // string | undefined  ✓

Config schema types ​

I18nKitConfig, LocaleConfig, LocaleMeta, I18nKitRules, and I18nKitIgnore — the types behind i18n-kit.config.json (see Configuration) — are exported as a types-only subpath:

ts
import type { I18nKitConfig, I18nKitRules, I18nKitIgnore } from 'vue-i18n-kit/config'

const rules: I18nKitRules = {
  warnOnHtmlTags: true,
  lengthWarningFactor: 3,
}

vue-i18n-kit/config has no runtime exports — importing anything other than import type { ... } from it resolves to an empty module.

I18nKitConfig ​

The full shape of i18n-kit.config.json, documented field-by-field on Configuration. Useful for type-checking a hand-written or programmatically-generated config file:

ts
import type { I18nKitConfig } from 'vue-i18n-kit/config'

const config: I18nKitConfig = {
  version: 1,
  localesDir: './locales',
  locales: [{ code: 'en', path: 'en.json' }],
}

LocaleConfig ​

One registered locale's entry inside I18nKitConfig.locales: code, path, optional meta (see LocaleMeta below), plus createdAt/updatedAt timestamps written by the CLI/editor.

LocaleMeta ​

The config file's own per-locale metadata shape: display?: string, flag?: string, direction?: 'ltr' | 'rtl', author?: string, version?: string, plus an open index signature for custom fields. This is a different, config-file-specific type from the runtime LocaleDefinition.meta: TMeta used by useLocale() and useAvailableLocales() — that one is fully consumer-defined via the generic, this one describes what the CLI/editor read and write in i18n-kit.config.json.

I18nKitRules ​

Fields: interpolationPatterns?: string[], lengthWarningFactor?: number, warnOnHtmlTags?: boolean, warnOnIcuErrors?: boolean, warnOnDuplicateValues?: boolean, minValueLength?: number. See Validation rules for defaults and behavior.

I18nKitIgnore ​

Fields: prune?: string[], duplicates?: string[], unused?: string[], scanExclude?: string[]. See Ignore lists for defaults and behavior.