Repository navigation
chore(i18n): add repository-native translation validation and integrity checks - #397
Merged
Merged
Conversation
…ty checks Expand tests/translations.test.ts into the safety gate for all i18n migration PRs and community contributions. Adds registry-to-file consistency, en-canonical leaf key parity, string leaf validity, ICU syntax validation via @formatjs/icu-messageformat-parser, placeholder and rich-text tag parity vs English, TypeScript key safety (exhaustively typed dynamic keys + AppConfig augmentation), and fixture-based negative tests for every failure mode. Fixes a real es.json plural mismatch and types previously untyped dynamic t() template literals in the WhatsApp and Setup pages. Adds an i18n:check alias for discoverability.
This was referenced Aug 19, 2026
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.
Intent
chore(i18n): add repository-native translation validation and integrity checks (issue #382, epic #372 Phase 1 final step). Commit 09508ec on branch chore/382-i18n-validation rewrites tests/translations.test.ts into a comprehensive safety gate: (1) registry-file consistency via languages.ts (BCP-47 tags, ltr/rtl direction); (2) exact nested leaf key parity with en.json as canonical (zero missing, zero orphan, incl. selectable:false fa); (3) string leaf validity (no non-string/empty/array/empty-object leaves, no corrupted strings); (4) ICU syntax validation of all messages via @formatjs/icu-messageformat-parser (new root devDependency ^3.5.17); (5) ICU placeholder argument + plural/select selector parity vs en.json; (6) rich-text tag parity vs en.json; (7) TypeScript key safety: literal t() keys defined, no unsafe template-literal t() calls (all dynamic keys now carry exhaustive as-casts in whatsapp/setup pages), messages.d.ts AppConfig augmentation present; (8) fa.json no-silent-English-fallback safeguards. Also fixes a real es.json plural mismatch (addonGroups.addCount) and adds npm run i18n:check alias. Negative fixture tests verify every failure mode is detected. Exclusions: do not modify translation wording/keys beyond the es.json addCount fix, do not touch backend runtime code, do not add new dependencies beyond @formatjs/icu-messageformat-parser, do not run or modify e2e playwright tests, do not modify CI workflows, keep commits free of AI attribution footers.
What Changed
tests/translations.test.tsusing@formatjs/icu-messageformat-parserto enforce registry consistency, leaf key parity against canonicalen.json, string leaf validity, ICU syntax and placeholder parity, rich-text tag parity, TypeScript key safety, and Persian fallback safeguards, backed by negative fixture tests.i18n:checknpm script alias, installed@formatjs/icu-messageformat-parserdev dependency, and updatedAGENTS.mdandCONTRIBUTING.mdwith translation verification guidelines.t()calls in the WhatsApp and Setup pages and updatedes.jsonto use correct ICU plural formatting foraddonGroups.addCount.Risk Assessment
✅ Low: The translation validation test suite and ICU message integrity checks are well-bounded, robustly tested with negative fixtures, and introduce no runtime risks.
Testing
Exercised the full i18n safety gate test suite (npm run i18n:check / npm run test:translations), verified ICU plural formatting for addonGroups.addCount across singular and plural counts, validated dynamic key resolution on WhatsApp and Setup screens, and confirmed all 16 negative fixture detection cases; visual UI screenshots were not applicable as this change is a repository-native translation validation and test integrity gate with type-level key assertions.
Evidence: i18n-check-output.log
> [email protected] i18n:check > npm run test:translations > [email protected] test:translations > ts-node --transpile-only -P tests/tsconfig.json tests/translations.test.ts Translation integrity: en <-> es <-> pt <-> fa ✓ registry ↔ files consistent (4 languages, 4 files) en.json: 2053 leaf keys es.json: 2053 leaf keys pt.json: 2053 leaf keys fa.json: 2053 leaf keys ✓ no duplicate keys within translation files ✓ exact leaf key parity with en.json (no missing, no orphan keys) ✓ all leaves are non-empty strings (no empty objects/arrays/null/booleans/numbers) ✓ no malformed values ✓ all messages parse as valid ICU (plurals, selects, brackets) ✓ placeholder arguments and plural/select selectors match en.json in all locales ✓ rich-text tags match en.json in all locales ✓ no undefined keys (1765 literal t() calls covered) ✓ no unsafe template-literal t() calls (all dynamic keys exhaustively cast) ✓ messages.d.ts AppConfig augmentation present (compile-time key checks active) ✓ no untranslated fa.json values (31 intentional shared values) ✅ All translation integrity checks passed. Negative tests (fixture-based): ✓ all negative fixtures detected by their validators ✅ All translation integrity checks + negative tests passed.Evidence: i18n-verification-summary.txt
=== FLO-CAFE i18n TRANSLATION VALIDATION & REPOSITORY INTEGRITY VERIFICATION REPORT === 1. PRODUCT BEHAVIOR: ICU Plural Formatting (addonGroups.addCount fix) -------------------------------------------------------------------------------- Raw ICU Templates: EN: {count, plural, one {# addon} other {# addons}} ES: {count, plural, one {# adicional} other {# adicionales}} PT: {count, plural, one {# adicional} other {# adicionais}} FA: {count, plural, one {# افزونه} other {# افزونه}} Formatted Output (End-User View): count = 1: EN: 1 addon ES: 1 adicional PT: 1 adicional FA: ۱ افزونه count = 5: EN: 5 addons ES: 5 adicionales PT: 5 adicionais FA: ۵ افزونه 2. TYPE-SAFE DYNAMIC TRANSLATION KEY RESOLUTION (WhatsApp & Setup pages) -------------------------------------------------------------------------------- WhatsApp Statuses: whatsapp.status.failed -> EN: "Failed" | ES: "Falló" | PT: "Falhou" | FA: "ناموفق" whatsapp.status.queued -> EN: "Queued" | ES: "En cola" | PT: "Na fila" | FA: "در صف" whatsapp.status.typing -> EN: "Typing" | ES: "Escribiendo" | PT: "Digitando" | FA: "در حال تایپ" whatsapp.status.sent -> EN: "Sent" | ES: "Enviado" | PT: "Enviada" | FA: "ارسالشده" whatsapp.status.delivered -> EN: "Delivered" | ES: "Entregado" | PT: "Entregue" | FA: "تحویلشده" whatsapp.status.read -> EN: "Read" | ES: "Leído" | PT: "Lida" | FA: "خواندهشده" WhatsApp Message Kinds: whatsapp.kind.bill_receipt -> EN: "Bill receipt" | ES: "Recibo" | PT: "Comprovante de conta" | FA: "رسید صورتحساب" whatsapp.kind.manual_reply -> EN: "Manual reply" | ES: "Respuesta manual" | PT: "Resposta manual" | FA: "پاسخ دستی" whatsapp.kind.auto_followup -> EN: "Auto follow-up" | ES: "Seguimiento automático" | PT: "Acompanhamento automático" | FA: "پیگیری خودکار" Setup Options: setup.emptyLabel -> EN: "Empty" | ES: "Vacío" | PT: "Vazio" | FA: "خالی" setup.expressLabel -> EN: "Express" | ES: "Express" | PT: "Expresso" | FA: "سریع" setup.demoLabel -> EN: "Demo" | ES: "Demo" | PT: "Demonstração" | FA: "نمایشی" 3. SAFETY GATE SUITE SUMMARY -------------------------------------------------------------------------------- Command: npm run i18n:check (alias for npm run test:translations) Checked Locales: en, es, pt, fa (2,053 leaf keys each, total 8,212 strings) Literal t() Calls Verified: 1,765 frontend call sites Result: 100% PASS across all 8 validation gates and fixture negative tests. ===Evidence: i18n-validation-evidence.log
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
tests/translations.test.ts:535-findDuplicateKeysis invoked during translation file loading and populatesdups, butdupsis never checked or asserted inrun(). As a result, duplicate keys within a translation JSON object are not rejected during test execution.🔧 Fix: assert duplicate keys in translation validation test
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run test:translationsnpm run i18n:checknpm run test:rtl-foundationnpm run test:rtl-setup-auth-settingsnpm run test:rtl-dashboard-pos-commonnpm run test:rtl-kds-server-whatsappIntlMessageFormat formatting for addonGroups.addCount across en, es, pt, faDynamic key resolution verification for WhatsApp and Setup pages across en, es, pt, fa✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.