Wörterbücher unter lib/i18n statt next-intl (Next.js 16 ist neu genug, dass eine externe Routing-Middleware zusätzliches Risiko bedeutet hätte); Sprache liegt in einem Cookie, kein URL-Präfix nötig, dadurch bleibt proxy.ts unverändert. LocaleProvider stellt Wörterbuch + Sprache per Context für Client-Komponenten bereit (lib/i18n/shared.ts ist bewusst getrennt von lib/i18n/index.ts, damit next/headers nicht in den Client-Bundle gelangt).
14 lines
401 B
TypeScript
14 lines
401 B
TypeScript
export const LOCALES = ["de", "en", "pl"] as const;
|
|
export type Locale = (typeof LOCALES)[number];
|
|
export const DEFAULT_LOCALE: Locale = "de";
|
|
|
|
export const LOCALE_LABELS: Record<Locale, string> = {
|
|
de: "Deutsch",
|
|
en: "English",
|
|
pl: "Polski",
|
|
};
|
|
|
|
export function isLocale(value: string | undefined | null): value is Locale {
|
|
return !!value && (LOCALES as readonly string[]).includes(value);
|
|
}
|