Skip to content

fix: PromptChoiceScreen subtitle showed target language instead of primary - #41

Merged
TrainTravel merged 1 commit into
mainfrom
fix/promptchoice-mislabeled-subtitle
May 26, 2026
Merged

fix: PromptChoiceScreen subtitle showed target language instead of primary#41
TrainTravel merged 1 commit into
mainfrom
fix/promptchoice-mislabeled-subtitle

Conversation

@TrainTravel

Copy link
Copy Markdown
Owner

Summary

PromptChoiceScreen rendered the heading and subtitle as identical strings — e.g. both lines read "Comment voulez-vous commencer ?" for any user on the default fr/en pair. The user hit this in screenshot.

Root cause

The subtitle used a Translations object with mis-keyed values:

// BEFORE — broken
<h2>{t({ fr: 'Comment voulez-vous commencer ?', en: 'How would you like to start?', es: '...' }).primary}</h2>
<p>{t({
  fr: 'Comment would you like to start?',         // ← ENGLISH under fr key
  en: 'Comment voulez-vous commencer ?',          // ← FRENCH under en key
  es: 'Comment voulez-vous commencer ?',          // ← FRENCH under es key
}).secondary}</p>

For target=fr primary=en, .secondary looks up the en key and got the French value — so the subtitle rendered French again, duplicating the heading visually.

Fix

Compute the heading once and use both .primary (target lang) and .secondary (primary lang) from the same Translations object:

const heading = t({
  fr: 'Comment voulez-vous commencer ?',
  en: 'How would you like to start?',
  es: '¿Cómo quieres empezar?',
  ja: 'どのように始めますか?',
  'zh-Hans': '你想怎么开始?',
  'zh-Hant': '你想怎麼開始?',
});
// ...
<h2>{heading.primary}</h2>
{heading.secondary !== heading.primary && <p>{heading.secondary}</p>}

The conditional render avoids showing the subtitle when both sides happen to resolve identically (e.g. target=ja primary=en both fall back to the en value if ja: were missing — same pattern as PR #39's bilingual() dedupe).

While here, added ja / zh-Hans / zh-Hant keys to all 7 t() calls on this screen — same pattern as PR #40's Tier 1 chrome sweep.

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run — 188 passed / 189 (only pre-existing useJournal startFreeWrite)
  • Manual: open PromptChoice with target=fr primary=en → heading reads French, subtitle reads English ("How would you like to start?")
  • Manual: target=ja primary=en → heading reads Japanese, subtitle reads English
  • Manual: target=zh-Hant primary=zh-Hans → heading reads Traditional, subtitle reads Simplified (not identical strings)

🤖 Generated with Claude Code

…imary

The screen rendered the heading and subtitle as identical strings —
e.g. both lines read "Comment voulez-vous commencer ?" for any user
on the default fr/en pair. Root cause was a mis-keyed Translations
object on the subtitle: the fr key held English text and the en
key held French text, so .secondary (looking up the primary lang)
returned the French value identical to what .primary already showed.

Fix: compute the heading once and use both .primary (target) and
.secondary (primary) from the same Translations object. Skip the
subtitle render when both sides resolve identically (e.g. target
falls back to en alongside primary=en).

While here, added ja / zh-Hans / zh-Hant keys to all 7 t() calls
on this screen — same pattern as the Tier 1 chrome translation
sweep in PR #40.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@TrainTravel
TrainTravel merged commit 94932ce 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