// Client-sicherer Teil von lib/i18n: keine Abhängigkeit auf next/headers, // darf daher auch von "use client"-Komponenten importiert werden. import { dictionaries, type Dict } from "./dictionaries"; import type { Locale } from "./locales"; export { LOCALES, LOCALE_LABELS, DEFAULT_LOCALE, isLocale } from "./locales"; export type { Locale } from "./locales"; export type { Dict } from "./dictionaries"; export const LOCALE_COOKIE = "locale"; export function getDictionary(locale: Locale): Dict { return dictionaries[locale]; } /** Platzhalter der Form "{name}" durch vars.name ersetzen. */ export function formatMessage( template: string, vars?: Record ): string { if (!vars) return template; return template.replace(/\{(\w+)\}/g, (match, key) => key in vars ? String(vars[key]) : match ); }