Repository navigation
Closed
Labels
Description
Context
FloCafe manages translations directly within the Git repository without any SaaS translation management platform (no Crowdin, Weblate, or Tolgee).
This issue establishes comprehensive, repository-native validation tooling and CI checks that serve as the safety gate for all subsequent component migration PRs and future community translation contributions.
Architectural Decision Relevant to This Issue
- Repository-Native Validation: Quality checks run entirely locally and in CI via standard npm scripts (e.g.
npm run test:translations/npm run i18n:check). - Explicit Dependencies: Direct dependency on parsing utilities (e.g.
@formatjs/icu-messageformat-parserorintl-messageformat) declared explicitly inpackage.jsondevDependencies, without relying on undeclared transitive imports. - Strict 100% Parity Invariant: Every committed message file in the repository—including in-progress
selectable: falselanguages (e.g. Persian feat(i18n): add Persian/Farsi and Iran support #241)—must maintain 100% leaf key parity withen.json.selectable: falsecontrols user-facing selection in the UI, not schema incompleteness in Git. - English Canonical Schema:
frontend/src/lib/i18n/messages/en.jsonis the authoritative definition of valid namespaces, keys, ICU variable signatures, and rich-text tags.
What to do
Enhance tests/translations.test.ts (and wire into npm test and npm run test:translations) to enforce:
1. Registry ↔ File Consistency
- Every language defined in
frontend/src/lib/i18n/languages.tshas an existing message JSON file inmessages/. - Every maintained message file in
frontend/src/lib/i18n/messages/has a corresponding entry in the registry. - Valid BCP-47 locale tags and text directions (
ltr/rtl).
2. Exact Nested Leaf Key Parity & String Leaf Validation
- Strict full key parity: Every nested leaf key path in
en.jsonmust exist ines.json,pt.json, andfa.json(zero missing keys, zero orphan extra keys). - Leaf type validity: Every leaf node must be a non-empty string. Reject null, boolean, numeric, object, or array values at leaf positions.
- Reject corrupted leaf strings: unescaped raw newlines, trailing JSON syntax leftovers (
",,",}), or unbalanced braces.
3. ICU Syntax Validation
- Parse every message string across all locales using an explicit parser (
@formatjs/icu-messageformat-parserorintl-messageformat). - Catch malformed plural rules, invalid case selectors, unclosed brackets, and syntax errors.
4. ICU Variable and Placeholder Parity
- Compare placeholder arguments between translations and canonical English (e.g. if English specifies
{count}, Spanish must not use{total}). - For plural and select patterns, verify that the selector argument variable matches English.
5. Rich-Text & Tag Placeholder Parity
- Where messages include rich-text tags or formatting wrappers (e.g.
<bold>...</bold>,<link>...</link>,<ltr>...</ltr>), verify that translations preserve matching opening and closing tag names.
6. TypeScript Key Safety & Unsafe Dynamic Key Checks
- Verify that
tsc --noEmitenforces compile-time type checking of translation keys againstAppConfiginmessages.d.ts. - Check frontend source for unsafe template-literal translation calls (e.g.
t(prefix.${var})), enforcing the use of exhaustively typed enum maps.
7. Persian Translation Safeguards
- Maintain existing checks ensuring
fa.jsondoes not silently fall back to English values, respecting the documented intentional identical list (brand names, format tokens, measurements).
What NOT to do
- Do NOT integrate Crowdin, Weblate, Tolgee, or any external localization SaaS.
- Do NOT allow partial translations as an acceptable merge state.
- Do NOT rely on undeclared transitive npm dependencies for message parsing.
Acceptance Criteria
-
npm run test:translationsenforces registry consistency, 100% leaf key parity across all committed locales, string leaf validity, ICU syntax validity, parameter placeholder parity, and rich-text tag parity. - Negative tests verify that CI fails on:
- Missing keys in any locale (including
selectable: falselocales) - Orphan extra keys in any locale
- Non-string or malformed leaf values
- Malformed ICU syntax
- Mismatched placeholder argument names vs. English
- Mismatched rich-text/formatting tags vs. English
- Invalid literal translation keys in TypeScript
- Missing keys in any locale (including
- All tests pass against the nested message structure.
Verification
npm run test:translations
npm run lint
npm run build:frontend
npm test
Activity
[-]chore(i18n): add CI checks for translation integrity[/-][+]chore(i18n): add repository-native translation validation and integrity checks[/+]khaira777 commentedon Aug 19, 2026
Status: implemented — no-mistakes pipeline running
What was built
tests/translations.test.tsis now the repository-native safety gate for all i18n migration PRs and community translation contributions. All eight required checks are live, plus fixture-based negative tests for every failure mode:languages.tslanguage has amessages/<lang>.jsonfile and vice versa; BCP-47 locale tags validated viaIntl.Locale(canonical form required); direction must beltr/rtl.en.jsonis canonical: zero missing keys and zero orphan extra keys ines/pt/fa, includingselectable: falsePersian (feat(i18n): add Persian/Farsi and Iran support #241).@formatjs/icu-messageformat-parser(new explicit root devDependency^3.5.17, no undeclared transitive imports).<bold>/<link>-style tags must match English.t('...')keys defined; no unsafe template-literal t(backtick prefix.${var} backtick) calls (all dynamic keys now carry exhaustiveascasts);messages.d.tsAppConfig augmentation verified present.fa.jsonstill must not silently fall back to English (documented intentional-identical list).Real bugs the new gate caught
es.jsonaddonGroups.addCountdropped the ICU plural form ({count} adicionalesvs English plural pattern) → fixed to{count, plural, one {# adicional} other {# adicionales}}.collectCalledKeys()extraction regex only matched 2-segment keys, silently skipping 3+ segment keys likewhatsapp.send.error.notConnected. Fixed — literalt()call coverage rose from 1,659 → 1,765.whatsapp.status.*,whatsapp.kind.*) and Setup page (setup.*Label/Desc/Details) — now exhaustively cast per the dashboard/PrepaidCheckout convention.Verification (all green locally)
npm run test:translations✅ (live checks + negative fixtures)npm run lint/npm run lint:backend✅ (0 errors)npm run build:frontend✅npm test✅ (full suite, incl. 65/65 authz-phase3)test:e2e-argentina-flow✅ 32/32Pipeline:
01M0BTK51W0YXPE68HWBVRTQYG— currently inreview; PR will be created automatically once all gates pass.khaira777 commentedon Aug 19, 2026
✅ Done — merged as
588cc8cvia PR #397All acceptance criteria met and verified:
npm run test:translationsenforces registry consistency, 100% leaf key parity vsen.json(all committed locales, incl.selectable:falsefa), string leaf validity, ICU syntax validity (@formatjs/icu-messageformat-parser, explicit root devDep^3.5.17), parameter placeholder parity, and rich-text tag parity.t()calls.npm test(already present) and exposed asnpm run i18n:check; documented inAGENTS.md/CONTRIBUTING.md.Bugs this gate caught before merge:
es.jsonaddonGroups.addCounthad dropped the ICU plural form → fixed.collectCalledKeys()regex only matched 2-segment keys, silently skipping 3+ segment keys (coverage 1,659 → 1,765) → fixed.t(\prefix.${var}`)` calls in WhatsApp + Setup pages → now exhaustively cast.Verification:
test:translations✅ · lint (frontend + backend) 0 errors ✅ ·build:frontend✅ · fullnpm test✅ ·e2e-argentina-flow32/32 ✅ · all 12 CI checks on PR #397 ✅Pipeline
01M0BTK51W0YXPE68HWBVRTQYG→ outcome: passed. Closing.khaira777 commentedon Aug 19, 2026
Closed as completed.
khaira777 commentedon Aug 19, 2026
Logging these for the record (post-merge follow-up):
1. Pipeline launch friction (no-mistakes)
no-mistakes axi runin the background (nohup ... > /tmp/nm-382.log 2>&1 &) silently failed — no log file, no process. Root cause: the very long--intentstring broke the shell invocation. Workaround that worked: write the intent to a file,INTENT=$(cat ...), then launch. For future runs, keep the intent in a file from the start.timeout 30after confirming the run started, the daemon continued but the CLI lost its binding to the run:no-mistakes axi respondinitially returnederror: no active run to respond to. The firstrespond --action fixthen blocked ~300s waiting for the next gate. Lesson: don't detach the CLI client from an active run — keep a responding terminal attached (or accept the parked gate and pollaxi status).2. Regression I introduced, caught by the pipeline (auto-fixed)
tests/translations.test.tsrewrite I dropped the duplicate-key assertion from the original test (dupswas computed but never checked). The no-mistakes review gate flagged it (i18n-test-unasserted-duplicate-keys) and auto-fixed it (commit49f350e6), also adding a negative fixture test. Verified in the merged result — the duplicate-key check is live again.3. Pre-existing bugs the new gate exposed (fixed in this PR)
es.jsonaddonGroups.addCounthad dropped the ICU plural form.collectCalledKeys()regex only matched 2-segment keys → 3+ segment keys likewhatsapp.send.error.notConnectedwere silently unchecked (coverage 1,659 → 1,765).4. Flaky
npm testfirst run (authz, not related to this change)npm testinvocation showedauthz-matrix-phase3failures (expected 403, got 400,staffList is not iterable). A full rerun logged to file passed 65/65 and the whole suite exited 0. Looks like environment/port contention from running it right after the frontend build; did not reproduce. CI on PR chore(i18n): add repository-native translation validation and integrity checks #397 (all 12 checks, incl.linux-testsshards) was green, so this is a local-run flake to keep an eye on, not a regression.5. Leftover merged file (from #374's pipeline, not this PR)
tests/issue-374-nested-messages-verification.test.ts(566 lines) is a no-mistakes evidence generator with hardcoded/var/folders/...paths that was merged with refactor(i18n): convert flat translation keys to nested message format #396. It is not wired into any npm script so CI is unaffected, but it should be removed in a follow-up PR.