fix: detect imported recipe language for Translate button (v0.33.1)
URL import extracts content in the source page's own language (no translation), but never recorded what that language was, so the Translate button's "recipe.language !== my locale" check always saw null and showed the button unconditionally. The extractor now returns a detected ISO 639-1 language code alongside the recipe. Photo import always writes in the caller's locale already (see its langInstruction) but never recorded that either — now sets it directly to locale since it's known, not detected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
All notable changes to Epicure are documented here. This file is mirrored in-app at `/changelog` (and in the admin dashboard) via `apps/web/lib/changelog.ts` — update both together.
|
||||
|
||||
## 0.33.1 — 2026-07-14 17:45
|
||||
|
||||
### Fixed
|
||||
- URL-imported recipes never recorded what language they were actually written in, so the Translate button couldn't tell whether translation was needed — the importer now detects the source page's language, and photo import records the language it always writes in.
|
||||
|
||||
## 0.33.0 — 2026-07-14 17:35
|
||||
|
||||
### Added
|
||||
|
||||
@@ -66,6 +66,12 @@ export async function POST(req: NextRequest) {
|
||||
cookMins: recipe.cookMins,
|
||||
dietaryTags: recipe.dietaryTags ?? {},
|
||||
aiGenerated: true,
|
||||
// The extraction prompt always writes the recipe in the caller's own
|
||||
// locale (see importFromPhoto's langInstruction) regardless of what
|
||||
// language the photo/label was in — so this *is* the recipe's
|
||||
// language, not a guess, and lets the Translate button correctly
|
||||
// stay hidden until the user's app language changes.
|
||||
language: locale,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import { dietaryTagsSchema, ingredientSchema, stepSchema } from "./recipe-schema
|
||||
|
||||
const ImportedRecipeSchema = z.object({
|
||||
recipeType: z.enum(["dish", "drink"]).describe("\"drink\" only for a beverage/cocktail (no cooking step) — \"dish\" for anything else, including if unsure."),
|
||||
language: z.string().min(2).max(10).describe("ISO 639-1 code of the language the recipe content (title/ingredients/steps) is actually written in, e.g. \"en\", \"fr\" — the source page's language, not a language to translate into."),
|
||||
title: z.string(),
|
||||
description: z.string().optional(),
|
||||
baseServings: z.number().int().min(1).optional(),
|
||||
@@ -42,7 +43,7 @@ export async function importFromUrl(url: string, config?: AiConfig): Promise<Imp
|
||||
model,
|
||||
schema: ImportedRecipeSchema,
|
||||
system:
|
||||
"You are an expert at extracting structured recipe data from web page text. Extract all recipe information accurately. For ingredients, separate quantity, unit, and name. For steps, extract timer durations in seconds when mentioned. Set recipeType to \"drink\" only for a beverage/cocktail with no cooking involved — never set cookMins for a drink.",
|
||||
"You are an expert at extracting structured recipe data from web page text. Extract all recipe information accurately, in the same language as the source page — do not translate it. For ingredients, separate quantity, unit, and name. For steps, extract timer durations in seconds when mentioned. Set recipeType to \"drink\" only for a beverage/cocktail with no cooking involved — never set cookMins for a drink. Set language to the ISO 639-1 code of the page's actual language.",
|
||||
prompt: `Extract the recipe from this web page:\n\nURL: ${url}\n\nContent:\n${cleaned}`,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mirrors CHANGELOG.md at the repo root — update both together.
|
||||
export const APP_VERSION = "0.33.0";
|
||||
export const APP_VERSION = "0.33.1";
|
||||
|
||||
export type ChangelogEntry = {
|
||||
version: string;
|
||||
@@ -11,6 +11,13 @@ export type ChangelogEntry = {
|
||||
};
|
||||
|
||||
export const CHANGELOG: ChangelogEntry[] = [
|
||||
{
|
||||
version: "0.33.1",
|
||||
date: "2026-07-14 17:45",
|
||||
fixed: [
|
||||
"URL-imported recipes never recorded what language they were actually written in, so the Translate button couldn't tell whether translation was needed — the importer now detects the source page's language, and photo import records the language it always writes in.",
|
||||
],
|
||||
},
|
||||
{
|
||||
version: "0.33.0",
|
||||
date: "2026-07-14 17:35",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@epicure/web",
|
||||
"version": "0.33.0",
|
||||
"version": "0.33.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "epicure",
|
||||
"version": "0.33.0",
|
||||
"version": "0.33.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "pnpm --filter web dev",
|
||||
|
||||
Reference in New Issue
Block a user