Skip to content

Available Locales

useAvailableLocales() returns a computed list of all locales registered in the plugin config. Each item is a LocaleInfo object containing the locale code and its metadata.

ts
import { useAvailableLocales } from 'vue-i18n-kit'

const { availableLocales } = useAvailableLocales()
// availableLocales.value →
// [
//   { code: 'en', meta: { display: 'English', flag: '🇬🇧' } },
//   { code: 'ru', meta: { display: 'Русский', flag: '🇷🇺' } },
// ]

Return value

availableLocales

ComputedRef<LocaleInfo[]> — all locales in declaration order. Each item has code: string and meta: TMeta | undefined.

Pass a generic type to get typed meta without casting:

ts
interface AppLocaleMeta {
  display: string
  flag: string
}

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