Skip to content

fix(i18n): add key-coverage guard, pseudo-locale, and convert Connect… - #1594

Open
Chigybillionz wants to merge 1 commit into
Fluxora-Org:mainfrom
Chigybillionz:fix/1389-i18n-guard-and-audit
Open

fix(i18n): add key-coverage guard, pseudo-locale, and convert Connect…#1594
Chigybillionz wants to merge 1 commit into
Fluxora-Org:mainfrom
Chigybillionz:fix/1389-i18n-guard-and-audit

Conversation

@Chigybillionz

Copy link
Copy Markdown

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

  • 250 i18n-routed keys in en.ts
  • ~620+ hardcoded user-facing strings across 71 source files
  • Largest clusters: ConnectWalletModal (~60+), Streams detail (~40+), Treasury overview (~30+), Recipient portal (~20+)

Guard Mechanism: Key-Coverage Test

A new test (src/i18n/__tests__/keyCoverage.test.ts) that:

  • Scans all .tsx/.ts files under src/ (excluding tests and i18n itself)
  • Extracts strings from JSX text content, aria-label, placeholder, title, alt, label, description attributes
  • Reports strings that already have i18n keys but aren't wired (known backlog — warning only)
  • Reports strings NOT in the catalog at all (currently console.warn; TODO: switch to hard fail once backlog is resolved)
  • Runs as part of npm run test — no ESLint infrastructure needed

Why 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 (set locale="zx" on I18nProvider):

  • Properly translated strings appear with [...] markers and accented characters
  • Hardcoded strings appear WITHOUT markers — making missing keys immediately visible
  • Interpolation placeholders {token} are preserved unchanged

Bounded Conversion: ConnectWalletModal

Converted ~60 hardcoded strings to t() calls across all wallet connection states:

  • Default view (wallet selection, terms)
  • Not installed / Rejected / Network mismatch / Timeout error states
  • Hardware wallet flow (device searching, device found, awaiting confirmation)
  • Hardware error states (locked, wrong app, unplugged, mobile unsupported)

English rendering is functionally identical.

Key Changes

  • src/i18n/en.ts — Added ~110 connectWallet.* translation keys
  • src/i18n/index.tsx — Registered "zx" pseudo-locale, imported createPseudoLocale
  • src/i18n/zx.tsNew — pseudo-locale with character transformation
  • src/components/ConnectWalletModal.tsx — Converted ~60 hardcoded strings to t() calls
  • src/i18n/__tests__/keyCoverage.test.tsNew — key-coverage guard test
  • src/i18n/__tests__/pseudoLocale.test.tsNew — 16 tests for pseudo-locale
  • src/components/__tests__/ConnectWalletModal.stateMachine.test.tsx — Updated test for interpolated text node

Trade-offs / Considerations

  • The key-coverage guard currently warns (not fails) because there are ~571 existing hardcoded strings. Once the backlog is resolved, it should be switched to a hard fail.
  • The network mismatch description lost <strong> tags around network labels due to i18n interpolation (minor visual difference).
  • The pseudo-locale is a developer tool — not meant for end users. It's wired into the Locale type but not exposed in any UI menu.

Testing

  • npx vitest run src/i18n62/62 passed (including 16 new pseudoLocale tests, 3 new keyCoverage tests)
  • npx vitest run src/components/__tests__/ConnectWalletModal47/47 passed
  • npx tsc --noEmit — no errors in changed files

CI Verification

  • npm run test src/i18n — passed
  • npx tsc --noEmit — passed (pre-existing errors in unrelated files remain)

Remaining Areas for Follow-up

Priority Area Files Est. strings
High Streams detail Streams.tsx ~40+
High Treasury overview ActivityHeatmap.tsx, RecentStreams.tsx, StreamsTable.tsx, etc. ~30+
High Recipient portal Recipient.tsx ~20+
Medium Treasury onboarding TreasuryOnboarding.tsx ~15+
Medium Navigation/Layout AppNavbar.tsx, Layout.tsx, Navbar.tsx, Footer.tsx ~10+
Medium CSV upload ColumnMappingStep.tsx, PreviewValidateStep.tsx ~10+
Low Remaining ~20 files Various ~130+

Please review this task. If there are any corrections, improvements, or adjustments needed, I'd appreciate your feedback. Thank you!

…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>
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.

The i18n layer ships a single en.ts locale with no guard against missing keys or hardcoded strings

1 participant