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

I18nKitRules and I18nKitIgnore — the types behind the rules and ignore fields in i18n-kit.config.json (see Configuration) — are exported as a types-only subpath:

ts
import type { 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.

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.

I18nKitConfig

The full shape of i18n-kit.config.json — not exported from vue-i18n-kit/config (it embeds Node-only concerns like integrations.viteConfigPath), documented field-by-field on Configuration.