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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user