fix(i18n): translate remaining recipe card/detail strings, localize AI responses

Recipe cards, the recipe detail page, and meal planner still rendered raw
"{n} servings"/"{n}m cook"/"{n} srv" text and untranslated difficulty labels
outside the earlier i18n pass. Also wires the user's locale into AI features
that previously always answered in English regardless of app language:
recipe chat, ingredient substitution, recipe ideas, and generate-from-idea.
The recipe-language picker in the AI generate dialog now defaults to the
user's locale instead of always defaulting to English.
This commit is contained in:
Arnaud
2026-07-02 08:25:51 +02:00
parent 01fdbb880b
commit 2154512e54
15 changed files with 64 additions and 24 deletions
@@ -14,6 +14,8 @@ const Schema = z.object({
model: z.string().optional(),
});
const LANG: Record<string, string> = { en: "English", fr: "French" };
export async function POST(req: NextRequest) {
const { session, response } = await requireSession();
if (response) return response;
@@ -30,11 +32,13 @@ export async function POST(req: NextRequest) {
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro", "aiCall");
const privateBio = await getUserPrivateBio(session!.user.id);
const locale = (session!.user as { locale?: string }).locale ?? "en";
const recipe = await generateRecipe(parsed.data.title, {
provider: parsed.data.provider,
model: parsed.data.model,
userContext: privateBio ?? undefined,
language: LANG[locale] ?? "English",
});
const recipeId = crypto.randomUUID();
@@ -50,7 +54,7 @@ export async function POST(req: NextRequest) {
difficulty: recipe.difficulty ?? null,
visibility: "private",
aiGenerated: true,
language: "en",
language: locale,
dietaryTags: recipe.dietaryTags ?? {},
tags: [],
});