diff --git a/ui/litellm-dashboard/src/i18n/index.ts b/ui/litellm-dashboard/src/i18n/index.ts new file mode 100644 index 00000000000..b1172a998eb --- /dev/null +++ b/ui/litellm-dashboard/src/i18n/index.ts @@ -0,0 +1,10 @@ +"use client"; + +// ./i18n.ts imports react-i18next, whose module scope calls React context APIs. +// Without this directive, importing the barrel from a server component (e.g. +// app/layout.tsx) evaluates that module in the server graph and the build fails +// with "createContext is not a function". +export { I18nProvider, useI18n } from "./I18nProvider"; +export { getI18n } from "./i18n"; +export type { Locale } from "./resources/registry"; +export { supportedLngs, NAMESPACES } from "./resources/registry"; diff --git a/ui/litellm-dashboard/src/i18n/types.d.ts b/ui/litellm-dashboard/src/i18n/types.d.ts new file mode 100644 index 00000000000..c264e4ee5af --- /dev/null +++ b/ui/litellm-dashboard/src/i18n/types.d.ts @@ -0,0 +1,23 @@ +/** + * Global i18next type augmentation. This file is owned by Agent 4 permanently. + */ +// This import makes this file a module, which turns `declare module` below into +// an augmentation instead of an ambient declaration that would shadow the whole +// i18next package's types. +import "i18next"; + +declare module "i18next" { + interface CustomTypeOptions { + defaultNS: "common"; + // Deliberately NO strict `resources` key augmentation here. i18next v26's + // typed qualified keys are fragile (colons stripped in the union, qualified + // non-default lookups typed `unknown`, resource-shape sensitivity) and, in + // this static-export dashboard, repeatedly broke `next build`'s type check + // for a benefit that is redundant with the guarantees we already have: + // - runtime key correctness is enforced by the readiness gate (ADR-03, + // no raw-key flash) and + // - en/zh key inventory is enforced by A7's check-keys CI gate. + // So keys are typed loosely (`string`), which compiles stably. Common-NS + // keys are still used unprefixed per `defaultNS`. + } +}