chore: dev-mode warning when i18n translation key is missing - #42
Merged
Conversation
stringFor() now logs to the dev console whenever a ja / zh-Hans / zh-Hant translation is requested but not present on the Translations object — making silent fallbacks visible while developing. [i18n] Missing ja translation, falling back to en: "Brain Dump" Memoized per (lang, en-value) pair so re-renders don't flood the console. Gated on import.meta.env.DEV — prod is byte-identical behavior, no warning, no perf cost. This is the early-warning system for the larger "kill the fallback" goal: when Tier 2/3 chrome translations land and CI is green for a sprint, the optional ja/zh-* keys on the Translations type get promoted to required and the fallback branch deletes entirely. 5 new tests cover: warns for missing ja, warns for missing zh-Hant, no warn when key present, no warn for fr/en/es, and dedupe behavior (3 lookups → 1 warning). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Adds a dev-mode console warning whenever
stringFor()falls back to the English value because aja,zh-Hans, orzh-Hanttranslation key is missing. Prod behavior is byte-identical — gated onimport.meta.env.DEV.Memoized per
(lang, en-value)pair so re-renders don't flood the console.Why
The "Write today / Write today" bug (PR #39) and the Spanish-using-French-CBT bug (PR #38) and the chrome-stays-English problem (PR #36) all share one root cause: silent fallbacks hide incomplete translations. PR #39's
bilingual()dedupe fixed the most visible symptom (X / Xrendering). This PR adds the surveillance layer so future fallbacks are visible during development, not discovered later via a user screenshot.Roadmap (not in this PR)
The honest end-state is to eliminate the fallback entirely:
Translationstype's optionalja/zh-Hans/zh-Hantkeys to required. Delete the fallback branch.Until step 4, this warning is the early-warning system.
Test plan
npx tsc --noEmit— cleannpx vitest run— 193 / 194 (only pre-existinguseJournal startFreeWritefails)LanguageContext.test.tsx:jakey (returns en value)zh-Hantkeyfr/en/eslookups (no fallback possible)npm run dev, open Home withtarget=ja, console flags every Tier-2 string that's not yet translatednpm run build && npm run preview) — no warnings in console🤖 Generated with Claude Code