Skip to content

fix: route Spanish targets to Spanish CBT scaffolding, not French - #38

Merged
TrainTravel merged 1 commit into
mainfrom
feat/spanish-cbt-translation
May 26, 2026
Merged

fix: route Spanish targets to Spanish CBT scaffolding, not French#38
TrainTravel merged 1 commit into
mainfrom
feat/spanish-cbt-translation

Conversation

@TrainTravel

Copy link
Copy Markdown
Owner

Summary

Fixes a latent routing bug preserved through the language-* consolidation in PR #36: Spanish learners were getting French Cognitive Behavioral Therapy prompts because targetLang === 'es' fell into the French branch of language-chat's cbtBlock and granularityBlock.

A Spanish journal entry could trigger:

Quand ça s'est passé, quelle a été ta première pensée ?

instead of the correct Spanish phrasing. That's an obvious quality bug for the emotional-granularity goal — coaching prompts have to be in the target language to function as language practice.

What changed

supabase/functions/language-chat/index.ts:

  • granularityBlock — added a Spanish branch with Spanish vague-emotion examples:

    • malagotado, desanimado, abrumado
    • estresadoansioso, desbordado, tenso
    • biensereno, agradecido, aliviado
    • tristemelancólico, nostálgico, decepcionado
    • contentoencantado, aliviado, entusiasmado
    • cansadoexhausto, agotado, vacío
  • cbtBlock — added a Spanish branch with all 6 CBT techniques translated:

    1. Thought Records: "¿Cuál fue tu primer pensamiento cuando eso pasó?"
    2. Cognitive Distortions: "Noto un patrón interesante aquí…" / "¿hay otra forma de verlo?"
    3. Behavioral Experiments: "¿Y si lo intentaras…?"
    4. Downward Arrow: "Si fuera cierto, ¿qué significaría para ti?"
    5. Evidence Gathering: "¿Qué evidencia tienes a favor de ese pensamiento? ¿Y en contra?"
    6. Values Alignment: "¿Por qué es importante esto para ti?"
  • Added explicit "use (informal), not usted" instruction — neutral Latin-American Spanish, appropriate register for a personal journaling/coaching context.

French CBT stays as the explicit default fallback. Zero behavior change for any other language (fr, zh-Hans, zh-Hant, ja).

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run — 188 passed / 189 (only pre-existing useJournal startFreeWrite)
  • Edge function code only — no React unit tests apply. Manual verification recommended after deployment.
  • Manual after merge: set target=Spanish, post a Spanish journal entry, verify the chat response uses Spanish CBT phrasing, not French.

Native review caveat

My Spanish is decent (better than my Japanese) but not native. The translations follow neutral Latin-American conventions. A native speaker pass via iTalki or r/translator is still worthwhile before high-volume Spanish users hit the app — same recommendation as the Japanese prompts. The same copy-paste critique template applies.

Out of scope

  • Spanish chrome translations for t() / bilingual() call sites (separate translation-pass PR)
  • Adjusting the en/es vague-word list in language-feedback (English keys are still hardcoded there; lower priority since the language NAME in the prompt is correctly interpolated)

🤖 Generated with Claude Code

Before this PR (and preserved through the PR #36 consolidation),
targetLang === 'es' fell into the French branch of cbtBlock and
granularityBlock inside language-chat. Spanish journal entries got
French Cognitive Behavioral Therapy prompts:
  "Quand ça s'est passé, quelle a été ta première pensée ?"

That's the wrong language for the coaching, and it undercuts the
emotional-granularity goal — coaching prompts have to be in the
target language for the user to engage with them as language
practice.

Changes:
- granularityBlock: new Spanish branch (mal → agotado/desanimado/
  abrumado; estresado → ansioso/desbordado/tenso; bien → sereno/
  agradecido/aliviado; etc.)
- cbtBlock: new Spanish branch with the 6 CBT techniques fully
  translated (Thought Records, Cognitive Distortions, Behavioral
  Experiments, Downward Arrow, Evidence Gathering, Values
  Alignment), and an explicit "use tú not usted" instruction for
  the journaling/coaching register

French CBT stays as the explicit default fallback. Zero behavior
change for fr / zh-Hans / zh-Hant / ja targets.

Latent bug, not a regression — it has existed since Spanish was
added. PR #36 surfaced it during consolidation; this PR fixes it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@TrainTravel
TrainTravel merged commit 2df886d into main May 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant