Skip to content

fix(i18n): card copy that bypassed the catalog, and the prop guard that let it - #2710

Merged
innolope-dev merged 2 commits into
devfrom
fix/card-i18n-gaps
Aug 18, 2026
Merged

fix(i18n): card copy that bypassed the catalog, and the prop guard that let it#2710
innolope-dev merged 2 commits into
devfrom
fix/card-i18n-gaps

Conversation

@innolope-dev

Copy link
Copy Markdown
Collaborator

Why

The card page reads as untranslated for es-419 / pt-BR users, and it is not the plumbing: every screen under src/components/Card/ calls useTranslations, the card namespace has 232 genuinely translated keys, and there is exactly one NextIntlClientProvider — above every route. What leaks is copy that never reaches the catalog.

The common cause is a guard gap. react/jsx-no-literals runs with ignoreProps: true, so it only inspects JSX children. Copy handed to a component as a prop is invisible to it, and that is precisely the shape that shipped English:

<InfoCard
    title={`$${(balanceDueCents / 100).toFixed(2)} will be debited based on your next deposit`}
    description="A recent card payment ended up higher than the amount held at checkout. …"
/>

ignoreProps cannot simply be flipped — variant="warning", icon="info" and type="button" are string literals too.

What changed

Card surface

Fix Where
Balance-due notice → card.yourCard.balanceDueTitle / balanceDueBody YourCardScreen
Card-receipt adjustment notice → transaction.cardRows.settlementAdjustedNotice CardAdjustmentNotice
Legal links follow the user's locale instead of hardcoded /en/ CardTermsScreen
Loading-overview error → card.errors.cardDetailsLoading LockCardModal, CancelCardModal

The five card-terms links pointed at peanut.me/en/card-esign, /en/card-terms-us, /en/card-privacy and friends. Those marketing pages are locale-routed and fall back to English prose when a document has no translation, so linking the user's own locale is strictly better than pinning /en/. The marketing locale set spells its tags differently from the app's (pt-br vs pt-BR), so the href goes through toMarketingLocale rather than the raw locale — pinned by a new test.

The two modal errors are worth a look: they sat two lines above siblings already using t('errors.*'), and unlike most throws in this codebase they are rendered straight into the modal's error slot rather than collapsed by the friendly-error mapper.

The guard

A local ESLint rule (eslint-rules/copy-props-from-catalog.js) covers the gap. It checks only props that carry prose, and only values that read as prose — two or more words, with each interpolation standing in as one word. label="CUIT" and title={`$${cents}`} stay legal; title={`${amount} will be debited …`} does not. Both edges are pinned by RuleTester cases.

It is a named rule rather than another no-restricted-syntax selector for a reason worth flagging in review: that array lives in the repo-wide src/** block, and flat config replaces rule options instead of merging them. Scoping a second no-restricted-syntax to the localized surface would have silently dropped the router.back, nuqs and toast guards exactly where they matter most.

Everything the rule found is fixed — no exception list, no follow-up debt:

  • add-money/[country]/bank reuses addMoney.errors.rateUnavailable, which already said this in three languages
  • ExchangeRate had two hardcoded labels plus three module-level English constants the rule structurally cannot see; all five now come from the catalog
  • "Exchange rate" existed twice once ExchangeRate needed it, so the transaction-row key moved to common — the duplicate-value drift test allows one key per string, and this is one string
  • MaintenanceBanner, the ReConsentModal title, and the dismiss aria-label on pending-task cards

Deliberately not changed

  • MantecaDepositInfo keeps "Razón Social" behind a documented one-line disable. It is the field name the user's Argentine banking app displays; translating it breaks the match they are transcribing. Same precedent as the glossary's verbatim Apple Wallet quote.
  • recover-wallet stays outside the guard's globs. It has zero useTranslations — an English-only recovery tool, like the fix-card-signature page already exempted right above it. Localizing it is its own job, not a silent glob widening that reds the build.
  • Backend reason prose on the application-status screen. Every code the API resolver emits already maps to identity.reasons.* except document_rejected, which is unmapped on purpose: it only ships with the self-heal classifier's specific instruction ("Your ID photo was blurry…"), and a generic catalog line would mask it. Closing that needs the classifier's stable action code on the wire — an api-ts change.

Locales

Keys added to en / es-419 / pt-BR. es-AR takes voseo overrides only where the es-419 string it inherits carries a tuteo verb (vuelvevolvé, reconocesreconocés, contactacontactá) — the glossary test checks es-AR resolved, so tuteo leaking through the fallback would fail.

Verification

  • pnpm jest — all suites green (note: git submodule update --init src/content is required or three suites fail on missing content)
  • tsc --noEmit clean
  • eslint . — 0 errors
  • prettier --check . — clean

Four card-surface strings rendered English regardless of the user's
language. The screens themselves are fully localized, so these read as
the page ignoring the preference:

- YourCardScreen's balance-due notice passed its title and description
  as literals. react/jsx-no-literals runs with ignoreProps: true, so
  copy handed to a component as a prop is invisible to the guard — the
  same shape as CardAdjustmentNotice on the card receipt, fixed here too.
- The five card-terms legal links hardcoded /en/. The marketing pages are
  locale-routed and fall back to English prose when a document has no
  translation, so linking the user's own locale is strictly better. The
  marketing tags differ from the app's in case (pt-br vs pt-BR), so the
  href goes through toMarketingLocale rather than the raw locale.
- Lock/CancelCardModal threw an English literal for the not-yet-loaded
  overview, two lines above siblings that use t(). Unlike most throws
  here, this one is rendered into the modal's error slot.

es-AR takes voseo overrides only where the es-419 string it inherits
carries a tuteo verb form.

Backend reason prose on the application-status screen is unchanged:
every code the resolver emits already maps to identity.reasons.* except
document_rejected, which is deliberately unmapped.
…iding

react/jsx-no-literals runs with ignoreProps: true and cannot be flipped —
every non-copy prop (variant="warning", icon="info", type="button") is a
string literal too. That blind spot is how the card balance-due notice and
the card-receipt adjustment notice shipped English to every locale from
screens where all other copy went through t().

Adds a local rule for the gap. It checks only props that carry prose and
only values that read as prose (two or more words, with each interpolation
standing in as one word), so ids, slugs and single tokens like label="CUIT"
stay legal while `${amount} will be debited …` does not. Both edges are
pinned by RuleTester cases.

It is a named rule rather than another no-restricted-syntax selector
because that array lives in the repo-wide block: redefining the rule for
the localized surface would replace it there, silently dropping the
router.back, nuqs and toast guards exactly where they matter most.

Clears every violation it found:
- add-money bank reuses addMoney.errors.rateUnavailable, which already said
  this in three languages
- ExchangeRate had two labels plus three module-level English constants the
  rule cannot see; all five now come from the catalog
- "Exchange rate" existed twice once ExchangeRate needed it, so the
  transaction-row key moves to common — the drift test allows one key per
  string, and this is one string
- MaintenanceBanner, ReConsentModal title, and the dismiss aria-label on
  the pending-task cards

MantecaDepositInfo keeps "Razón Social": it is the field name the user's
Argentine banking app shows, and translating it breaks the match they are
transcribing.

recover-wallet stays outside the guard's globs. It has no useTranslations
at all — an English-only recovery tool, like the fix-card-signature page
already exempted above it. Localizing it is its own job.
@innolope-dev innolope-dev self-assigned this Aug 17, 2026
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview Aug 17, 2026 10:13pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 326494bd-70b8-4566-828f-c19042388aed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@innolope-dev

Copy link
Copy Markdown
Collaborator Author

Alternative: #2711 lands the same change on main

This PR and #2711 carry identical changes; pick one, close the other.

  • This one (→ dev) is the normal route. It reaches users after the next devmain promotion, and reaches the mobile app only after a further mainmobile-release sync — the native build ships from mobile-release. Since the bug was reported in the mobile app, that is two hops of latency.
  • fix(i18n): card copy that bypassed the catalog, and the prop guard that let it (main) #2711 (→ main) is the same two commits cherry-picked onto origin/main, so it skips the first hop. It applied cleanly and was re-verified from scratch on the main base (231 suites / 2953 tests, tsc clean, eslint . 0 errors, prettier clean) — worth noting because main and dev have diverged by 94/63 commits and the i18n catalogs differ by ~220 keys between them, so a clean cherry-pick was not a given.

Whichever merges, the other's branch should be deleted rather than merged too — merging both would replay the same catalog inserts and conflict.

One thing neither PR does: get this into the app. Both stop at a web branch. The card fix only reaches the native binary once the change is on mobile-release, so if this is worth shipping to the users who reported it, it needs that sync as a follow-up (direct merge — per repo rules mobile-release does not take PRs).

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 7159.84 → 7166.31 (+6.47)
Findings: 0 net (+34 new, -34 resolved)

🆕 New findings (34)

  • critical complexity — src/components/TransactionDetails/TransactionDetailsReceipt.tsx — CC 173, MI 51.72, SLOC 443
  • critical complexity — src/app/(mobile-ui)/add-money/[country]/bank/page.tsx — CC 113, MI 57.31, SLOC 396
  • critical complexity — src/components/Home/PendingVerificationTasks.tsx — CC 67, MI 62.42, SLOC 208
  • high hotspot — src/app/(mobile-ui)/add-money/[country]/bank/page.tsx — 63 commits, +594/-503 lines since 6 months ago
  • high hotspot — src/components/TransactionDetails/TransactionDetailsReceipt.tsx — 51 commits, +752/-1288 lines since 6 months ago
  • high method-complexity — src/app/(mobile-ui)/add-money/[country]/bank/page.tsx:58 — BridgeBankOnrampPage CC 33 SLOC 180
  • high complexity — src/components/Card/LockCardModal.tsx — CC 19, MI 48.9, SLOC 99
  • high complexity — src/components/ExchangeRate/index.tsx — CC 18, MI 45.86, SLOC 64
  • medium high-mdd — src/app/(mobile-ui)/add-money/[country]/bank/page.tsx:58 — BridgeBankOnrampPage: MDD 167.1 (uses across many lines from declarations)
  • medium high-mdd — src/components/Card/CancelCardModal.tsx:26 — CancelCardModal: MDD 63.6 (uses across many lines from declarations)
  • medium high-mdd — src/components/Card/YourCardScreen.tsx:31 — YourCardScreen: MDD 55.4 (uses across many lines from declarations)
  • medium high-mdd — src/components/Card/LockCardModal.tsx:45 — LockCardModal: MDD 47.0 (uses across many lines from declarations)
  • medium high-mdd — src/components/Home/PendingVerificationTasks.tsx:72 — PendingVerificationTasks: MDD 45.7 (uses across many lines from declarations)
  • medium high-mdd — src/components/Global/ReConsentModal/index.tsx:40 — ReConsentModal: MDD 34.9 (uses across many lines from declarations)
  • medium structural-dup — components/Card/CancelCardModal.tsx:62 — 30 duplicate lines / 123 tokens with components/Card/LockCardModal.tsx:68
  • medium high-mdd — src/components/Card/CardTermsScreen.tsx:46 — CardTermsScreen: MDD 29.6 (uses across many lines from declarations)
  • medium complexity — src/components/Global/ReConsentModal/index.tsx — CC 29, MI 59.09, SLOC 152
  • medium complexity — src/components/Card/CancelCardModal.tsx — CC 24, MI 52.24, SLOC 128
  • medium high-mdd — src/components/ExchangeRate/index.tsx:15 — ExchangeRate: MDD 24.3 (uses across many lines from declarations)
  • medium complexity — src/components/Card/CardTermsScreen.tsx — CC 22, MI 65.61, SLOC 109

…and 14 more.

✅ Resolved (34)

  • src/components/TransactionDetails/TransactionDetailsReceipt.tsx — CC 173, MI 51.73, SLOC 443
  • src/app/(mobile-ui)/add-money/[country]/bank/page.tsx — CC 113, MI 57.34, SLOC 395
  • src/components/Home/PendingVerificationTasks.tsx — CC 67, MI 62.39, SLOC 206
  • src/app/(mobile-ui)/add-money/[country]/bank/page.tsx — 62 commits, +593/-500 lines since 6 months ago
  • src/components/TransactionDetails/TransactionDetailsReceipt.tsx — 50 commits, +751/-1287 lines since 6 months ago
  • src/app/(mobile-ui)/add-money/[country]/bank/page.tsx:58 — BridgeBankOnrampPage CC 33 SLOC 179
  • src/components/Card/LockCardModal.tsx — CC 19, MI 49.02, SLOC 98
  • src/components/ExchangeRate/index.tsx — CC 18, MI 47.47, SLOC 55
  • src/app/(mobile-ui)/add-money/[country]/bank/page.tsx:58 — BridgeBankOnrampPage: MDD 166.0 (uses across many lines from declarations)
  • src/components/Card/CancelCardModal.tsx:26 — CancelCardModal: MDD 64.1 (uses across many lines from declarations)
  • src/components/Card/YourCardScreen.tsx:31 — YourCardScreen: MDD 54.9 (uses across many lines from declarations)
  • src/components/Card/LockCardModal.tsx:45 — LockCardModal: MDD 47.5 (uses across many lines from declarations)
  • src/components/Home/PendingVerificationTasks.tsx:72 — PendingVerificationTasks: MDD 43.4 (uses across many lines from declarations)
  • src/components/Card/CardTermsScreen.tsx:41 — CardTermsScreen: MDD 32.2 (uses across many lines from declarations)
  • src/components/Global/ReConsentModal/index.tsx:40 — ReConsentModal: MDD 32.2 (uses across many lines from declarations)
  • components/Card/CancelCardModal.tsx:62 — 30 duplicate lines / 120 tokens with components/Card/LockCardModal.tsx:68
  • src/components/Global/ReConsentModal/index.tsx — CC 29, MI 59.16, SLOC 151
  • src/components/Card/CancelCardModal.tsx — CC 24, MI 52.33, SLOC 127
  • src/components/Card/YourCardScreen.tsx — CC 22, MI 58.94, SLOC 76
  • src/components/Card/CardTermsScreen.tsx — CC 20, MI 65.55, SLOC 99

…and 14 more.

📈 Painscore deltas (top movers)

File Before After Δ
src/components/Global/Banner/MaintenanceBanner.tsx 0.5 2.9 +2.3
src/components/ExchangeRate/index.tsx 10.9 12.7 +1.7
src/components/TransactionDetails/provider-rows/CardAdjustmentNotice.tsx 6.3 7.5 +1.2

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 3085 ran, 0 failed, 0 skipped, 53.0s

📊 Coverage (unit)

metric %
statements 67.0%
branches 52.0%
functions 57.4%
lines 67.8%
⏱ 10 slowest test cases
time test
3.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
1.1s src/utils/__tests__/demo-api.test.ts › isDemoMode() is false when not running under Capacitor
0.5s src/utils/__tests__/url.utils.test.ts › uses the public BASE_URL in Capacitor, not the localhost WebView origin
0.4s src/utils/__tests__/auth-token.test.ts › authReady does not park — hydrates the plain token without an unlock
0.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.3s src/utils/__tests__/sentry.utils.test.ts › defaults to the client budget under a browser global
0.3s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in validateInviteCode
0.3s src/app/(mobile-ui)/withdraw/__tests__/withdraw-states.test.tsx › Bank withdrawal keeps the $1 minimum for sub-$1 amounts
0.3s src/utils/__tests__/sentry.utils.test.ts › still lets a per-call timeoutMs win over the default
0.3s src/utils/__tests__/auth-token.test.ts › ignores the guarded marker and falls back to the plain token
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@innolope-dev
innolope-dev merged commit b8a3029 into dev Aug 18, 2026
20 checks passed
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