import type { NuxtI18nOptions } from '@nuxtjs/i18n'; import { SUPPORTED_LOCALES } from '../app/constants'; import { createProjectKey } from "../app/utils/transliterator"; export function createI18nConfig(defaultLocaleCode?: string, projectName: string): NuxtI18nOptions { const defaultLocale = defaultLocaleCode && SUPPORTED_LOCALES.some(l => l.code === defaultLocaleCode) ? defaultLocaleCode : 'en-gb'; const cookieKey = `${createProjectKey(projectName)}-locale`; return { defaultLocale, locales: SUPPORTED_LOCALES.map((locale) => ({ code: locale.code, file: locale.file, })), lazy: true, strategy: 'prefix', detectBrowserLanguage: { alwaysRedirect: true, redirectOn: 'root', fallbackLocale: defaultLocale, cookieKey, }, }; }