summaryrefslogtreecommitdiff
path: root/internal/image/nanobanana.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-02 21:59:36 +0300
committerPaul Buetow <paul@buetow.org>2026-04-02 21:59:36 +0300
commit74383d0e31fee5aebec002971ebd2cbddad32ac7 (patch)
tree06663e2fa2d515b1ee1e26840417f5d193a71430 /internal/image/nanobanana.go
parentd94fdaf92d7c66c012e819c73632be16f346b66f (diff)
task 009/00i: remove internal translation from image clients; consolidate provider normalization
- task 009: remove translateBulgarianToEnglish from OpenAIClient and NanoBananaClient. Image clients no longer make internal translation API calls; callers must supply SearchOptions.Translation (processor and GUI already do). When translation is absent, opts.Query (the Bulgarian word) is used as fallback subject so image generation still proceeds. Update tests to pass translation via SearchOptions rather than relying on the removed fallback. - task 00i: consolidate duplicate ProviderGemini/ProviderOpenAI constants and normalizeProvider() functions from internal/translation and internal/phonetic into a shared config.NormalizeProvider(string) string in internal/config/provider.go. Both packages now delegate to the shared function so the normalization rule (lowercase, trim, default "gemini") has one authoritative home. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/image/nanobanana.go')
-rw-r--r--internal/image/nanobanana.go37
1 files changed, 9 insertions, 28 deletions
diff --git a/internal/image/nanobanana.go b/internal/image/nanobanana.go
index 1f3ac57..1a3d6ad 100644
--- a/internal/image/nanobanana.go
+++ b/internal/image/nanobanana.go
@@ -242,19 +242,20 @@ func (c *NanoBananaClient) ensureReady() error {
return nil
}
-func (c *NanoBananaClient) resolveTranslation(ctx context.Context, opts *SearchOptions, translation string) (string, error) {
+// resolveTranslation returns the English translation for the Bulgarian query.
+// Translating internally would couple the image package to the Gemini text API for a
+// concern that belongs in the translation package. Callers (processor, GUI) already
+// resolve the English translation before calling Search, so we simply use what was
+// provided and fall back to the original query word when nothing was given.
+func (c *NanoBananaClient) resolveTranslation(_ context.Context, opts *SearchOptions, translation string) (string, error) {
if translation != "" {
fmt.Printf("Using provided translation: %s -> %s\n", opts.Query, translation)
return translation, nil
}
- translation, err := c.translateBulgarianToEnglish(ctx, opts.Query)
- if err != nil {
- fmt.Printf("Translation failed: %v, using original word\n", err)
- return opts.Query, nil
- }
-
- return translation, nil
+ // No translation provided — fall back to the original query word so image
+ // generation still proceeds, albeit potentially with lower quality.
+ return opts.Query, nil
}
func (c *NanoBananaClient) resolvePrompt(ctx context.Context, opts *SearchOptions, translatedWord string) (string, error) {
@@ -332,26 +333,6 @@ func (c *NanoBananaClient) createEducationalPrompt(ctx context.Context, bulgaria
return buildEducationalPrompt(selectedStyle, scene, subject)
}
-func (c *NanoBananaClient) translateBulgarianToEnglish(ctx context.Context, word string) (string, error) {
- fmt.Printf("Nano Banana Translation: Using model '%s' to translate '%s'\n", c.textModelName(), word)
-
- translation, err := nanoBananaGenerateText(
- ctx,
- c,
- c.textModelName(),
- "You are a Bulgarian language expert. Translate the Bulgarian word into English. Respond with only the English translation, nothing else.",
- fmt.Sprintf("Translate the Bulgarian word '%s' to English. Respond with only the English translation, nothing else.", word),
- 0.3,
- 50,
- )
- if err != nil {
- return "", fmt.Errorf("translation failed: %w", err)
- }
-
- fmt.Printf("Translated '%s' to '%s'\n", word, translation)
- return translation, nil
-}
-
func (c *NanoBananaClient) generateSceneDescription(ctx context.Context, bulgarianWord, englishTranslation string) (string, error) {
fmt.Printf("Nano Banana Scene Generation: Creating scene for '%s' (%s)\n", bulgarianWord, englishTranslation)