fix(i18n): add key-coverage guard, pseudo-locale, and convert Connect… - #1594
Open
Chigybillionz wants to merge 1 commit into
Open
fix(i18n): add key-coverage guard, pseudo-locale, and convert Connect…#1594Chigybillionz wants to merge 1 commit into
Chigybillionz wants to merge 1 commit into
Conversation
…WalletModal (Fluxora-Org#1389) - Audit: 250 i18n-routed keys vs ~620+ hardcoded strings across 71 files - Add key-coverage test that scans source files for hardcoded strings - Add pseudo-locale (zx) that wraps strings in markers to make missing keys visible - Convert ConnectWalletModal (~60 strings) from hardcoded to i18n-routed - Update ConnectWalletModal test for interpolated text node matching - English rendering is functionally identical 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.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.
PR Description
// markdown
Fix: Add i18n key-coverage guard, pseudo-locale, and convert ConnectWalletModal
Summary
This PR addresses issue #1389 by adding audit, guard, and second-locale infrastructure to the i18n layer, and converting the largest hardcoded-string cluster (ConnectWalletModal) as a proof of concept.
Issue
Closes #1389
Root Cause
The i18n layer had infrastructure (typed keys, interpolation, pluralization) but no mechanism to detect when components bypass it. With only one locale (English), missing keys silently fall back to English — making the gap invisible until a second locale is added.
Solution Implemented
Audit Result
en.tsGuard Mechanism: Key-Coverage Test
A new test (
src/i18n/__tests__/keyCoverage.test.ts) that:.tsx/.tsfiles undersrc/(excluding tests and i18n itself)aria-label,placeholder,title,alt,label,descriptionattributesconsole.warn; TODO: switch to hard fail once backlog is resolved)npm run test— no ESLint infrastructure neededWhy a test, not an ESLint rule: The lint gate is currently disabled for a documented backlog. A rule that can't run provides zero protection. The test runs unconditionally via
vitest.Second Locale: Pseudo-Locale (
zx)A pseudo-locale (
src/i18n/zx.ts) that transforms every string to[Čřéáţé şţŕéáм]. When activated (setlocale="zx"onI18nProvider):[...]markers and accented characters{token}are preserved unchangedBounded Conversion: ConnectWalletModal
Converted ~60 hardcoded strings to
t()calls across all wallet connection states:English rendering is functionally identical.
Key Changes
src/i18n/en.ts— Added ~110connectWallet.*translation keyssrc/i18n/index.tsx— Registered"zx"pseudo-locale, importedcreatePseudoLocalesrc/i18n/zx.ts— New — pseudo-locale with character transformationsrc/components/ConnectWalletModal.tsx— Converted ~60 hardcoded strings tot()callssrc/i18n/__tests__/keyCoverage.test.ts— New — key-coverage guard testsrc/i18n/__tests__/pseudoLocale.test.ts— New — 16 tests for pseudo-localesrc/components/__tests__/ConnectWalletModal.stateMachine.test.tsx— Updated test for interpolated text nodeTrade-offs / Considerations
<strong>tags around network labels due to i18n interpolation (minor visual difference).Localetype but not exposed in any UI menu.Testing
npx vitest run src/i18n— 62/62 passed (including 16 new pseudoLocale tests, 3 new keyCoverage tests)npx vitest run src/components/__tests__/ConnectWalletModal— 47/47 passednpx tsc --noEmit— no errors in changed filesCI Verification
npm run test src/i18n— passednpx tsc --noEmit— passed (pre-existing errors in unrelated files remain)Remaining Areas for Follow-up
Streams.tsxActivityHeatmap.tsx,RecentStreams.tsx,StreamsTable.tsx, etc.Recipient.tsxTreasuryOnboarding.tsxAppNavbar.tsx,Layout.tsx,Navbar.tsx,Footer.tsxColumnMappingStep.tsx,PreviewValidateStep.tsxPlease review this task. If there are any corrections, improvements, or adjustments needed, I'd appreciate your feedback. Thank you!