Files
whyrating/packages/i18n/src/config.ts
2026-02-04 01:55:00 +01:00

50 lines
1014 B
TypeScript

import { logger } from "@turbostarter/shared/logger";
import { env } from "./env";
import type { InitOptions, Namespace } from "i18next";
export const config = {
locales: ["en", "es"],
defaultLocale: env.NEXT_PUBLIC_DEFAULT_LOCALE,
namespaces: [
"common",
"admin",
"organization",
"dashboard",
"auth",
"billing",
"marketing",
"validation",
],
cookie: "locale",
} as const;
export const getInitOptions = ({
locale,
defaultLocale,
ns,
}: {
locale?: string;
defaultLocale?: string;
ns?: Namespace;
}): InitOptions => ({
supportedLngs: config.locales,
fallbackLng: defaultLocale ?? config.defaultLocale,
lng: locale,
defaultNS: config.namespaces,
fallbackNS: config.namespaces,
ns: ns ?? config.namespaces,
preload: false,
interpolation: {
escapeValue: false,
},
missingInterpolationHandler: (text, value, options) => {
logger.debug(
`Missing interpolation value for key: ${text}`,
value,
options,
);
},
});