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:
@@ -38,7 +38,7 @@ func initApp(appConfig *config.Config, pool *pgxpool.Pool) (*App, error) {
|
||||
mainPexelsAPIKey := newPexelsAPIKey(appConfig)
|
||||
pexelsClient := newPexelsClient(mainPexelsAPIKey)
|
||||
userProductRepository := userproduct.NewRepository(pool)
|
||||
recommendationHandler := recommendation.NewHandler(openaiClient, pexelsClient, userRepository, userProductRepository)
|
||||
recommendationHandler := recommendation.NewHandler(openaiClient, openaiClient, pexelsClient, userRepository, userProductRepository)
|
||||
dishRepository := dish.NewRepository(pool)
|
||||
savedrecipeRepository := savedrecipe.NewRepository(pool, dishRepository)
|
||||
savedrecipeHandler := savedrecipe.NewHandler(savedrecipeRepository)
|
||||
@@ -59,7 +59,7 @@ func initApp(appConfig *config.Config, pool *pgxpool.Pool) (*App, error) {
|
||||
recognitionHandler := recognition.NewHandler(openaiClient, productRepository, jobRepository, kafkaProducer, sseBroker)
|
||||
|
||||
menuRepository := menu.NewRepository(pool)
|
||||
menuHandler := menu.NewHandler(menuRepository, openaiClient, pexelsClient, userRepository, userProductRepository, dishRepository)
|
||||
menuHandler := menu.NewHandler(menuRepository, openaiClient, openaiClient, dishRepository, pexelsClient, userRepository, userProductRepository, dishRepository)
|
||||
diaryRepository := diary.NewRepository(pool)
|
||||
diaryHandler := diary.NewHandler(diaryRepository, dishRepository, dishRepository)
|
||||
homeHandler := home.NewHandler(pool)
|
||||
|
||||
Reference in New Issue
Block a user