This commit is contained in:
greeneclipse committed 2026-10-14 20:02:42 +02:00
1 parent 3b0d692839
commit 8b540d22bc
14 files changed
+526 -82

No files matched your search

@@ -150,3 +150,19 @@ func TestRunSteps_defaultFormulaDrivesGeneration(t *testing.T) {
}
_ = company.DefaultLanguage
}
// Without a stored category prompt, fallback content must still use the target
// product's language, not default to old English HTML instructions.
func TestWithDefaultCategoryFormula_localizedFallback(t *testing.T) {
for _, lang := range []string{"en", "hr", "sl", "de", "ja"} {
input := ProductInput{CategoryUniqueID: "grohe", CategoryDisplayName: "Bathroom faucets", Language: lang}
got := withDefaultCategoryFormula(input)
expected, err := aiprompts.OfflineDefaultPrompt(lang)
if err != nil {
t.Fatal(err)
}
if got.CategoryEnhancePrompt != expected {
t.Fatalf("%s fallback uses wrong language", lang)
}
}
}
@@ -95,7 +95,14 @@ func withDefaultCategoryFormula(in ProductInput) ProductInput {
if def.Overlay == "" {
return in
}
// The language selected for product processing must also select the
// formula language, even when this is an uncached legacy category.
in.CategoryEnhancePrompt = def.Overlay
if lang := company.NormalizeLanguage(in.Language); company.IsAllowedLanguage(lang) {
if localized, err := aiprompts.OfflineDefaultPrompt(lang); err == nil {
in.CategoryEnhancePrompt = localized
}
}
if in.TitleTemplate == nil && def.TitleTemplateJSON != "" {
in.TitleTemplate = decodeOptionalJSONObject([]byte(def.TitleTemplateJSON))
}