Skip to content

test: enforce shared locale glossary on app i18n catalogs - #2674

Merged
abalinda merged 2 commits into
devfrom
test/i18n-glossary-check
Aug 12, 2026
Merged

test: enforce shared locale glossary on app i18n catalogs#2674
abalinda merged 2 commits into
devfrom
test/i18n-glossary-check

Conversation

@kushagrasarathe

@kushagrasarathe kushagrasarathe commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

App UI strings (~2,200 keys × 3 locales) and marketing/content prose sit on the same screen but had no shared terminology governance — terms and register could drift ("monedero" vs "billetera", tuteo leaking into es-AR). The glossary now lives in mono content/_system/glossary/glossary.{es-419,es-ar,pt-br}.md (extracted from the locale context files). This PR adds the enforcement half: a jest suite that checks the app catalogs against the glossary's deterministic subset — banned terms and wrong-register verb forms.

An audit of the current catalogs on dev found zero real violations, so this PR is the test only. Key design points (hardened after automated review):

  • es-AR is checked resolved (en ⊕ es-419 ⊕ delta, same as loadMessages) — a new es-419 string with tuteo needs a voseo override before it reaches Argentine users.
  • Exceptions are per-rule, not global — card.addToWallet.iosStep3 (quotes Apple Wallet's own menu label) is exempt only from the debit/prepaid-card rule.
  • Patterns are NBSP-proof (\s+ between phrase words) and accept accent-dropped variants where the unaccented form is not a legitimate word in that locale.
  • A guard test fails when a new locale JSON ships without glossary rules.
  • Shared catalog flatten helpers extracted to catalog-helpers.ts (messages/shhhhh tests had two private copies; this PR would have added a third).

Task

TASK-21172 — Localization governance: shared glossary + tone (app ↔ content)

Design notes / accepted trade-offs

  • Term lists are hardcoded here rather than parsed from mono (mono is not available in CI); the glossary files are the source of truth and both sides say to keep them in sync.
  • The "sem CPF" rule is stricter than the glossary (which allows one positively-framed body use) — app strings are short CTA-like copy; per-rule exceptions handle any future legit use.
  • DeepPartial is now exported from messages.ts (type-only, no runtime change) so the test can resolve es-AR synchronously.

Risks / breaking changes

None — test-only plus one type export. No runtime code touched.

QA

npx jest src/i18n/app/__tests__ — 90 tests including 20 glossary checks across es-419 / es-AR / pt-BR. Regexes negative-tested (accented-word boundaries: "vosotros" does not false-positive the vos rule; "Pagas" tuteo does not false-positive the voseo rule).

Screenshots: N/A (no visible change)

Content pages and app UI strings share the same screen but had no shared
terminology governance (TASK-21172). The glossary now lives in mono
content/_system/glossary/; this test enforces its deterministic subset
(banned terms, wrong-register verb forms) so new keys can't reintroduce
drift like monedero/billetera or tuteo in es-AR.
@vercel

vercel Bot commented Aug 12, 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 12, 2026 8:50am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: e0718eb6-dab0-4ce2-815a-4b92c26b3078

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
📝 Walkthrough

Walkthrough

The change adds glossary-compliance tests for es-419, es-AR, and pt-BR. The tests recursively inspect catalog values, exclude approved third-party UI quotes, and validate locale-specific terminology rules.

Changes

Locale glossary compliance

Layer / File(s) Summary
Glossary rule validation
src/i18n/app/__tests__/glossary.test.ts
Adds recursive catalog traversal, approved quote exclusions, locale-specific regular-expression rules, and assertions for zero glossary violations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the glossary-enforcement tests added for app locale catalogs.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/i18n-glossary-check

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

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 7158.11 → 7158.24 (+0.13)
Findings: 0 net (+0 new, -0 resolved)

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 2951 ran, 0 failed, 0 skipped, 52.8s

📊 Coverage (unit)

metric %
statements 66.3%
branches 51.2%
functions 56.4%
lines 67.0%
⏱ 10 slowest test cases
time test
3.8s 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.4s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in validateInviteCode
0.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.4s src/utils/__tests__/auth-token.test.ts › is none — never guarded — when only the guarded marker is present
0.3s src/utils/__tests__/auth-token.test.ts › ignores the guarded marker and falls back to the plain token
0.3s src/utils/__tests__/sentry.utils.test.ts › defaults to the client budget under a browser global
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__/auth-token.test.ts › authReady does not park — hydrates the plain token without an unlock
0.3s src/utils/__tests__/sentry.utils.test.ts › still lets a per-call timeoutMs win over the default
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@kushagrasarathe

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/i18n/app/__tests__/glossary.test.ts`:
- Around line 15-18: Limit the card.addToWallet.iosStep3 Apple Wallet exemption
to the pt-BR debit/prepaid-card validation rule instead of removing the key
globally through EXCEPTIONS. Update the affected locale-rule checks while
preserving the Apple menu-label allowance and ensuring other rules still
validate this key.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5d863794-5db0-47ed-b7f2-dc22d9e2ce00

📥 Commits

Reviewing files that changed from the base of the PR and between ad5b61b and 707de18.

📒 Files selected for processing (1)
  • src/i18n/app/__tests__/glossary.test.ts

Comment thread src/i18n/app/__tests__/glossary.test.ts Outdated
- check es-AR resolved (en + es-419 + delta) so new es-419 tuteo strings
  need a voseo override before reaching Argentine users
- scope exceptions per rule (a third-party-UI quote no longer exempts a
  key from every rule; also drops the prototype-chain 'in' hazard)
- \s+ between phrase words (NBSP-proof) and safe accent-dropped variants
- add es debit/prepaid card rule, pt-BR circumvention + tu-form bans,
  and a guard that every non-en locale has rules
- extract shared catalog flatten helpers (third copy was being added)
@kushagrasarathe
kushagrasarathe marked this pull request as ready for review August 12, 2026 09:22
@kushagrasarathe
kushagrasarathe requested review from Hugo0 and removed request for Hugo0 August 12, 2026 09:22
@abalinda
abalinda merged commit 60a51fb into dev Aug 12, 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.

2 participants