Package APIs

@i18n-micro/vue

Exported API of @i18n-micro/vue, generated from the source.

Vue 3 bindings for i18n-micro — composables, components, and routing helpers.

Entry points: @i18n-micro/vue, @i18n-micro/vue/router.

@i18n-micro/vue

Components

I18nGroup

const I18nGroup: DefineComponent
prefix
string required
groupClass
string
Default''
const I18nLink: DefineComponent
to
I18nRouteTarget required
activeStyle
CSSProperties
Default{}
localeRoute
(to: I18nRouteTarget, locale?: string) => string | { path?: string; }

I18nSwitcher

const I18nSwitcher: DefineComponent

I18nT

function I18nT(props: I18nTProps): any

See I18nTProps

Composables

useI18n

Get the i18n instance from the Vue app context Returns the same instance that was created with createI18n()

function useI18n(options?: UseI18nOptions): { … }

See UseI18nOptions

useLocaleHead

function useLocaleHead(options?: UseLocaleHeadOptions): { … }
metaObject
Ref<{ htmlAttrs: { [x: string]: string | undefined; lang?: string | undefined; dir?: "ltr" | "rtl" | "auto" | undefined; }; link: ({ [x: string]: string | undefined; rel: "canonical"; href: string; } | { [x: string]: string | undefined; rel: "alternate"; href: string; hreflang: string; })[]; meta: { [x: string]: string; property: string; content: string; }[]; }, LocaleHead | { htmlAttrs: { [x: string]: string | undefined; lang?: string | undefined; dir?: "ltr" | "rtl" | "auto" | undefined; }; link: ({ [x: string]: string | undefined; rel: "canonical"; href: string; } | { [x: string]: string | undefined; rel: "alternate"; href: string; hreflang: string; })[]; meta: { [x: string]: string; property: string; content: string; }[]; }> required
updateMeta
(canonicalQueryWhitelist?: string[]) => void required

See UseLocaleHeadOptions

Functions

createI18n

function createI18n(options: CreateI18nOptions): I18nPlugin

See CreateI18nOptions · I18nPlugin

Classes

VueI18n

class VueI18n extends BaseI18n {
  constructor(options: VueI18nOptions)
}

See BaseI18n · VueI18nOptions

Constants

I18nDefaultLocaleKey

const I18nDefaultLocaleKey: InjectionKey<string>

I18nInjectionKey

const I18nInjectionKey: InjectionKey<VueI18n>

See VueI18n

I18nLocalesKey

const I18nLocalesKey: InjectionKey<Locale[]>

See Locale

Types

I18nPlugin

type I18nPlugin = Plugin & { … }
global
VueI18n required
setRoutingStrategy
(strategy: I18nRoutingStrategy) => void required

I18nRouteTarget

A link target: a path with its query and hash, or a location (a named one needs a router that resolves names).

type I18nRouteTarget = string | {
  path?: string;
  name?: string | symbol;
  params?: object;
  query?: object;
  hash?: string;
}

I18nRoutingStrategy

Routing strategy interface for i18n Implement this interface to integrate with any router library

interface I18nRoutingStrategy
getCurrentPath
() => string required
Returns current path (without locale prefix if needed, or full path) Used for determining active classes in links
linkComponent
string | Component
Component to use for rendering links (e.g., RouterLink)
push
(target: { path: string; }) => void required
Function to navigate to another route/locale
replace
(target: { path: string; }) => void required
Function to replace current route
resolvePath
(to: I18nRouteTarget, locale: string) => string | { path?: string; }
Generate path for specific locale
toHref
(path: string) => string
href of a path from resolvePath, for a router that navigates by something else (VitePress: paths are relative to the site base, the address bar is not)
getRoute
() => { fullPath: string; query: Record<string, unknown>; }
(Optional) Get current route object for SEO/Meta tags

I18nTProps

interface I18nTProps

UseI18nOptions

interface UseI18nOptions
locales
Locale[]
defaultLocale
string

UseLocaleHeadOptions

interface UseLocaleHeadOptions
addDirAttribute
boolean
identifierAttribute
string
addSeoAttributes
boolean
baseUrl
string | (() => string)
hreflangBaseLanguage
boolean
Defaultfalse · Also emit bare-language hreflang tags derived from iso (never from routing code).

VueI18nOptions

interface VueI18nOptions

Re-exports

Declared in another package of this repository and documented on its page.

@i18n-micro/vue/router

Also exports, as @i18n-micro/vue does: I18nRoutingStrategy.

Functions

createVueRouterAdapter

Factory for Vue Router adapter Implements routing utilities for Vue Router Uses vue-router APIs for navigation and path resolution

function createVueRouterAdapter(
  router: Router,
  locales: Locale[],
  defaultLocale: string,
): I18nRoutingStrategy

See Locale · I18nRoutingStrategy


Generated from the TypeScript sources and their JSDoc by pnpm run docs:generate. Back to all packages · Integration guides