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:
@@ -14,6 +14,7 @@ import {
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
type Provider = "openai" | "anthropic" | "openrouter" | "ollama" | "";
|
||||
|
||||
@@ -59,6 +60,7 @@ type Prefs = {
|
||||
};
|
||||
|
||||
export function ModelPrefsForm({ initialPrefs }: { initialPrefs: Prefs | null }) {
|
||||
const t = useTranslations("settingsForm");
|
||||
const [prefs, setPrefs] = useState<Prefs>(initialPrefs ?? {});
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
@@ -75,9 +77,9 @@ export function ModelPrefsForm({ initialPrefs }: { initialPrefs: Prefs | null })
|
||||
body: JSON.stringify(prefs),
|
||||
});
|
||||
if (!res.ok) throw new Error("Save failed");
|
||||
toast.success("Model preferences saved");
|
||||
toast.success(t("modelSaved"));
|
||||
} catch {
|
||||
toast.error("Failed to save");
|
||||
toast.error(t("modelSaveFailed"));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
@@ -132,7 +134,7 @@ export function ModelPrefsForm({ initialPrefs }: { initialPrefs: Prefs | null })
|
||||
onValueChange={(v) => setField(modelKey, v === "default" ? null : v)}
|
||||
>
|
||||
<SelectTrigger className="h-8 text-sm">
|
||||
<SelectValue placeholder="Default" />
|
||||
<SelectValue placeholder={t("modelDefaultPlaceholder")} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="default">
|
||||
@@ -149,7 +151,7 @@ export function ModelPrefsForm({ initialPrefs }: { initialPrefs: Prefs | null })
|
||||
) : (
|
||||
<Input
|
||||
className="h-8 text-sm"
|
||||
placeholder={provider ? "e.g. llama3.2" : "—"}
|
||||
placeholder={provider ? t("modelNamePlaceholder") : "—"}
|
||||
value={model}
|
||||
onChange={(e) => setField(modelKey, e.target.value)}
|
||||
disabled={!provider}
|
||||
|
||||
Reference in New Issue
Block a user