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:
Arnaud
2026-07-02 07:58:18 +02:00
parent afff6cf9eb
commit 01fdbb880b
32 changed files with 515 additions and 187 deletions
@@ -1,6 +1,7 @@
"use client";
import { useState } from "react";
import { useTranslations } from "next-intl";
import { cn } from "@/lib/utils";
import { Check, Package, Loader2 } from "lucide-react";
import { toast } from "sonner";
@@ -23,6 +24,8 @@ export function ShoppingListView({
listId: string;
initialItems: Item[];
}) {
const t = useTranslations("mealPlan");
const tShopping = useTranslations("shoppingLists");
const [items, setItems] = useState<Item[]>(initialItems);
const [movingToPantry, setMovingToPantry] = useState(false);
@@ -43,8 +46,8 @@ export function ShoppingListView({
})),
}),
});
if (!res.ok) { toast.error("Failed to move items to pantry"); return; }
toast.success(`${checkedItems.length} item${checkedItems.length !== 1 ? "s" : ""} added to pantry`);
if (!res.ok) { toast.error(t("moveToPantryFailed")); return; }
toast.success(t("addedToPantry", { count: checkedItems.length }));
} finally {
setMovingToPantry(false);
}
@@ -61,7 +64,7 @@ export function ShoppingListView({
}
const grouped = items.reduce<Record<string, Item[]>>((acc, item) => {
const key = item.aisle ?? "Other";
const key = item.aisle ?? t("aisleOther");
(acc[key] ??= []).push(item);
return acc;
}, {});
@@ -69,17 +72,17 @@ export function ShoppingListView({
const checkedCount = items.filter((i) => i.checked).length;
if (items.length === 0) {
return <p className="text-muted-foreground text-sm">This list is empty.</p>;
return <p className="text-muted-foreground text-sm">{t("listEmptyState")}</p>;
}
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<p className="text-sm text-muted-foreground">{checkedCount}/{items.length} checked</p>
<p className="text-sm text-muted-foreground">{tShopping("checkedCount", { checked: checkedCount, total: items.length })}</p>
{checkedCount > 0 && (
<Button size="sm" variant="outline" onClick={moveToPantry} disabled={movingToPantry}>
{movingToPantry ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <Package className="h-3.5 w-3.5" />}
Move {checkedCount} to pantry
{t("moveToPantry", { count: checkedCount })}
</Button>
)}
</div>