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 { toast } from "sonner";
|
||||
import { Key, Trash2, Check } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -17,6 +18,7 @@ const PROVIDERS: { id: Provider; label: string; placeholder: string }[] = [
|
||||
];
|
||||
|
||||
export function ByokManager({ initialKeys }: { initialKeys: string[] }) {
|
||||
const t = useTranslations("settingsForm");
|
||||
const [configuredKeys, setConfiguredKeys] = useState<Set<string>>(new Set(initialKeys));
|
||||
const [inputs, setInputs] = useState<Partial<Record<Provider, string>>>({});
|
||||
const [saving, setSaving] = useState<Provider | null>(null);
|
||||
@@ -35,9 +37,9 @@ export function ByokManager({ initialKeys }: { initialKeys: string[] }) {
|
||||
if (res.ok) {
|
||||
setConfiguredKeys((prev) => new Set([...prev, provider]));
|
||||
setInputs((prev) => ({ ...prev, [provider]: "" }));
|
||||
toast.success(`${provider} key saved`);
|
||||
toast.success(t("byokSaved", { provider }));
|
||||
} else {
|
||||
toast.error("Failed to save key");
|
||||
toast.error(t("byokSaveFailed"));
|
||||
}
|
||||
} finally {
|
||||
setSaving(null);
|
||||
@@ -50,9 +52,9 @@ export function ByokManager({ initialKeys }: { initialKeys: string[] }) {
|
||||
const res = await fetch(`/api/v1/ai-keys/${provider}`, { method: "DELETE" });
|
||||
if (res.ok) {
|
||||
setConfiguredKeys((prev) => { const s = new Set(prev); s.delete(provider); return s; });
|
||||
toast.success(`${provider} key removed`);
|
||||
toast.success(t("byokRemoved", { provider }));
|
||||
} else {
|
||||
toast.error("Failed to remove key");
|
||||
toast.error(t("byokRemoveFailed"));
|
||||
}
|
||||
} finally {
|
||||
setRemoving(null);
|
||||
|
||||
Reference in New Issue
Block a user