import en from "@/messages/en.json"; import fr from "@/messages/fr.json"; const catalogs = { en, fr } as const; export type Locale = keyof typeof catalogs; export function getMessages(locale: string | undefined | null) { return catalogs[locale as Locale] ?? catalogs.en; } export function formatMessage(template: string, vars: Record) { return template.replace(/\{(\w+)\}/g, (_, key) => String(vars[key] ?? "")); }