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.

6 lines (5 loc) 424 B
import { getQuery, getCookie } from "h3"; export const detectCurrentLocale = (event, config, defaultLocale) => { const { fallbackLocale, defaultLocale: configDefaultLocale } = config; return (event.context.params?.locale || getQuery(event)?.locale || getCookie(event, "user-locale") || event.headers.get("accept-language")?.split(",")[0] || fallbackLocale || defaultLocale || configDefaultLocale || "en").toString(); };