feat: translate recommendations and menu dishes into user language

- Generate recipes in English (reverted prompt to English-only)
- Add TranslateRecipes to OpenAI client (translate.go) — sends compact
  JSON payload of translatable fields, merges back into original recipes
- recommendation/handler.go: translate recipes in-memory before response
  when lang != "en"; falls back to English on error
- dish/repository.go: Create() now returns (dishID, recipeID, err) so
  callers can upsert dish_translations after saving
- menu/handler.go: saveRecipes returns savedRecipeEntry slice with dishID;
  saveDishTranslations calls TranslateRecipes then UpsertTranslation for
  each dish when the request locale is not English
- savedrecipe/repository.go: updated to ignore dishID from Create()
- init.go: wire openaiClient as RecipeTranslator and dishRepository as
  DishTranslator for menu.NewHandler

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
dbastrikin
2026-03-23 17:40:19 +02:00
parent cba50489be
commit bffeb05a43
7 changed files with 278 additions and 55 deletions

View File

@@ -136,10 +136,10 @@ func (r *Repository) Save(ctx context.Context, userID string, req SaveRequest) (
}
}
var err error
recipeID, err = r.dishRepo.Create(ctx, cr)
if err != nil {
return nil, fmt.Errorf("create dish+recipe: %w", err)
var saveError error
_, recipeID, saveError = r.dishRepo.Create(ctx, cr)
if saveError != nil {
return nil, fmt.Errorf("create dish+recipe: %w", saveError)
}
}