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.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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] ?? ""));
|
||||
}
|
||||
Reference in New Issue
Block a user