01fdbb880b
Wires dozens of components and server pages to next-intl instead of hardcoded English text, and adds a lightweight getMessages/formatMessage helper for server components (print pages, public recipe page, cook metadata) since next-intl/server isn't wired into this app's routing. Backfills missing en/fr message keys that existing code already referenced but fr.json lacked.
15 lines
448 B
TypeScript
15 lines
448 B
TypeScript
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<string, string | number>) {
|
|
return template.replace(/\{(\w+)\}/g, (_, key) => String(vars[key] ?? ""));
|
|
}
|