feat: dedupe bilingual() identical sides + add CTA ja/zh translations - #39
Merged
Merged
Conversation
This was referenced May 26, 2026
Fixes the "Write today / Write today" rendering when target=ja and
primary=zh-Hant (or any pair where both sides fall back to en via
the Translations fallback chain).
Two changes:
1. bilingual() dedupe — one-line change in LanguageContext.tsx.
When target and primary resolve to the same string, render once
instead of "X / X". Silent improvement for every existing call
site without modifying their Translations objects.
2. HomeScreen CTA gets explicit ja + zh-Hans + zh-Hant keys.
"Write today" / "Write another" now render in the target
language when those are the active target:
ja: 今日書きましょう / もう一度書きましょう
zh-Hans: 今天写日记 / 再写一篇
zh-Hant: 今天寫日記 / 再寫一篇
Three new bilingual() tests cover the dedupe behavior:
- Same string both sides → renders once
- Different strings → keeps "X / Y" pair
- Both keys provided → renders the actual pair (no false dedupe)
Other chrome anchors (Brain Dump, Thought Garden, etc.) still
fall back to en but no longer say "Brain Dump / Brain Dump" —
the dedupe handles them transparently. A future translation-pass
PR will add real Japanese and Chinese keys.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TrainTravel
force-pushed
the
feat/bilingual-dedupe-and-cta-i18n
branch
from
May 26, 2026 23:35
74d1d5e to
35a62f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the "Write today / Write today" rendering when the active language pair has no translation for either side (e.g. target=ja and primary=zh-Hant, where both fall back to
envia the Translations fallback chain).Two changes
1.
bilingual()dedupes identical sides (structural fix)One-line change in
src/contexts/LanguageContext.tsx:When
targetLangandprimaryLangresolve to the same string, render once instead of"X / X". Silent improvement for every bilingual() call site across the app — no API change, no semantic change for pairs that legitimately differ (e.g.fr / en).This means chrome strings without
ja:/zh-*:keys silently improve too:"Brain Dump / Brain Dump"becomes"Brain Dump"when both sides fall back to en.2. CTA gets explicit Japanese + Simplified Chinese + Traditional Chinese (per-call site fix)
The most visually prominent bilingual call on HomeScreen. "Write today" / "Write another" now render in the target language:
今日書きましょう/もう一度書きましょう(polite, inviting register matching the encouragement tone of the button)今天写日记/再写一篇今天寫日記/再寫一篇Other chrome anchors (
Brain Dump,Thought Garden,French journaling practice,More tools, etc.) are NOT translated in this PR — the dedupe handles their visual ugliness, and a translation-pass PR will fill in real ja / zh-* keys for them.Test plan
npx tsc --noEmit— cleannpx vitest run— 191 passed / 192 (only pre-existinguseJournal startFreeWrite)LanguageContext.test.tsx:今日書きましょう / 今天寫日記instead ofWrite today / Write todayÉcrire aujourd'hui / Write today(no regression)Brain Dumponce instead ofBrain Dump / Brain DumpNative review caveat
I picked the Japanese and Chinese phrasings myself. For
今日書きましょうI went with polite-encouraging register matching the button's vibe (not curt今日書く, not heavy今日の日記を書きましょう). A native pass via iTalki would catch any awkwardness — same recommendation as the Japanese prompts from PR #36.Out of scope (follow-up translation pass)
ja:/zh-*:keys to other bilingual() call sites (Brain Dump,Thought Garden, etc.)t()call sites in journaling-flow screensformatDatelocale handling forprimary=zh-*/target=ja(currently falls back toen-US)🤖 Generated with Claude Code