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:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Languages, Loader2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
@@ -32,6 +33,7 @@ const LANGUAGES = [
|
||||
];
|
||||
|
||||
export function TranslateButton({ recipeId }: { recipeId: string }) {
|
||||
const t = useTranslations("ai.translate");
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [targetLanguage, setTargetLanguage] = useState("French");
|
||||
@@ -48,12 +50,12 @@ export function TranslateButton({ recipeId }: { recipeId: string }) {
|
||||
|
||||
if (!res.ok) {
|
||||
const err = await res.json() as { error?: string };
|
||||
toast.error(err.error ?? "Failed to translate recipe");
|
||||
toast.error(err.error ?? t("error"));
|
||||
return;
|
||||
}
|
||||
|
||||
const { id } = await res.json() as { id: string };
|
||||
toast.success("Translation saved as new draft recipe");
|
||||
toast.success(t("success"));
|
||||
setOpen(false);
|
||||
router.push(`/recipes/${id}/edit`);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user