This commit is contained in:
2025-08-17 13:21:01 +02:00
commit c988d51438
51 changed files with 5742 additions and 0 deletions

15
lib/i18n.ts Normal file
View File

@@ -0,0 +1,15 @@
export const supportedLocales = ['en', 'de'] as const;
export type Locale = typeof supportedLocales[number];
export function getInitialLocale(cookieStore: any, _hdrs: any): Locale {
const cookie = cookieStore?.get?.('lang')?.value as Locale | undefined;
if (cookie && (supportedLocales as readonly string[]).includes(cookie)) return cookie;
return 'en';
}
export async function getDictionary(locale: Locale) {
// Use relative imports to ensure resolution in both server and edge runtimes
const common = await import(`../locales/${locale}/common.json`).then((m) => m.default);
const home = await import(`../locales/${locale}/home.json`).then((m) => m.default);
return { common, home, ...home } as any;
}