Files
Epicure/apps/web/lib/i18n/server.ts
T
Arnaud 01fdbb880b feat(i18n): translate hardcoded strings across print, public recipe, and recipe management UI
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.
2026-07-02 07:58:18 +02:00

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] ?? ""));
}