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 { useRouter } from "next/navigation";
import { Wand2, Loader2, X } from "lucide-react";
import { toast } from "sonner";
@@ -26,6 +27,7 @@ export function AdaptRecipeButton({
recipeId: string;
ingredients: Ingredient[];
}) {
const t = useTranslations("recipe");
const router = useRouter();
const [open, setOpen] = useState(false);
const [excluded, setExcluded] = useState<Set<string>>(new Set());
@@ -50,7 +52,7 @@ export function AdaptRecipeButton({
async function handleAdapt() {
if (excluded.size === 0 && !extraConstraints.trim()) {
toast.error("Select at least one ingredient to exclude or add a constraint");
toast.error(t("adaptConstraintRequired"));
return;
}
@@ -68,7 +70,7 @@ export function AdaptRecipeButton({
if (!res.ok) {
const err = await res.json() as { error?: string };
toast.error(err.error ?? "Failed to adapt recipe");
toast.error(err.error ?? t("adaptFailed"));
return;
}
@@ -154,7 +156,7 @@ export function AdaptRecipeButton({
id="extra-constraints"
value={extraConstraints}
onChange={(e) => setExtraConstraints(e.target.value)}
placeholder="e.g. Make it vegan, lower the calories, use pantry staples only, gluten-free…"
placeholder={t("adaptConstraintPlaceholder")}
rows={2}
disabled={adapting}
/>