UNPKG

nuxt-i18n-micro

Version:

Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.

39 lines (38 loc) 1.3 kB
import { useNuxtApp } from "#app"; export function useI18n() { const nuxtApp = useNuxtApp(); const injections = { $i18nStrategy: nuxtApp.$i18nStrategy, $getI18nConfig: nuxtApp.$getI18nConfig, $defaultLocale: nuxtApp.$defaultLocale, $getLocale: nuxtApp.$getLocale, $getLocaleName: nuxtApp.$getLocaleName, $getLocales: nuxtApp.$getLocales, $getRouteName: nuxtApp.$getRouteName, $t: nuxtApp.$t, $_t: nuxtApp.$_t, $ts: nuxtApp.$ts, $_ts: nuxtApp.$_ts, $tn: nuxtApp.$tn, $td: nuxtApp.$td, $tdr: nuxtApp.$tdr, $has: nuxtApp.$has, $tc: nuxtApp.$tc, $mergeTranslations: nuxtApp.$mergeTranslations, $setI18nRouteParams: nuxtApp.$setI18nRouteParams, $switchLocaleRoute: nuxtApp.$switchLocaleRoute, $switchLocalePath: nuxtApp.$switchLocalePath, $switchLocale: nuxtApp.$switchLocale, $switchRoute: nuxtApp.$switchRoute, $localeRoute: nuxtApp.$localeRoute, $localePath: nuxtApp.$localePath, $loadPageTranslations: nuxtApp.$loadPageTranslations, $setMissingHandler: nuxtApp.$setMissingHandler, helper: nuxtApp.helper }; const noDollarInjections = Object.fromEntries(Object.entries(injections).map(([key, value]) => [key.slice(1), value])); return { ...injections, ...noDollarInjections }; }