Skip to content

fix(content): opportunities are generated in English regardless of the brand's language #363

Closed

Description

@gkhngyk

Problem

When a brand's language is set to something other than English (e.g. Turkish, chosen during onboarding), the Content Optimization opportunities (/dashboard/content) are still generated in English. They should be written in the brand's language.

Root cause (from the code)

The content-opportunity generator never tells the LLM which language to write in — unlike the other AI-generation flows, which already do.

In server/src/workers/content-worker.js, processContentJob:

  • fetches the brand with select('id, name, description, industry, organization_id') — language is not selected;
  • OPPORTUNITY_SYSTEM_PROMPT and the built userPrompt contain no language instruction;
  • so generateObject({ system: OPPORTUNITY_SYSTEM_PROMPT, prompt: userPrompt, … }) defaults to English.

For contrast, the flows that do it right: the prompt-suggestion generator resolves getLanguageName(brand.language) and instructs the model to write in that language (see loadSuggestionContext / generateSuggestions in server/src/routes/prompts.js), and the topic/competitor suggestion routes append e.g. IMPORTANT: All … MUST be written in ${langName}.

Proposed change

Mirror the existing pattern in content-worker.js:

  1. Add language to the brand select(...).
  2. import { getLanguageName } from '../lib/languages.js'; and resolve const langName = getLanguageName(brand.language);.
  3. Add a language directive to the generation prompt, e.g. append to the system prompt or the user prompt: IMPORTANT: Write every opportunity title and description in ${langName}.

The opportunity type / impact enums stay as-is (they're internal values, not shown-as-text) — only the human-readable title and description need to be in the brand's language.

How to test

  1. Create/set a brand whose language is Turkish (or any non-English), then generate Content Optimization opportunities.
  2. The generated titles and descriptions come back in that language (Turkish), not English.
  3. An English brand still gets English opportunities (no regression).

Notes

  • Server-only change in the content generation worker; no schema or web change.
  • Uses the existing getLanguageName helper and the same convention as prompt/topic/competitor suggestions.

Activity

  1. added
    bug
    help wanted
    on Jul 7, 2026
  2. Sam-syntax35 commented on Jul 7, 2026

    @Sam-syntax35
    Contributor

    please assign this to me! i willl be happy to contribute on this

  3. gkhngyk commented on Jul 7, 2026

    @gkhngyk
    ContributorAuthor

    Thanks @Sam-syntax35 — assigned to you! 🎉 In server/src/workers/content-worker.js (processContentJob): add language to the brand select(...), import { getLanguageName } from '../lib/languages.js', resolve const langName = getLanguageName(brand.language), and add a directive to the prompt like IMPORTANT: Write every opportunity title and description in ${langName}. — mirrors the prompt-suggestion / topic-suggestion flows. Only title/description need translating; the type/impact enums stay as-is. Ping here if anything's unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions