Locale QA harness (local)
Version: 2.9
Last Updated: 2026-08-06 15:45:39
Spec: docs/superpowers/specs/2026-08-04-i18n-fr-local-ai-review-design.md
Findings that drove v2: consolidated quality review
Agent rules: locale quality · locale runtime (language-agnostic UI) · frontend i18n
Originally French-specific; from v2 the harness is language-agnostic, and from v2.1 no script, npm alias, or findings path carries a language in its name. Adding a locale means adding data to quality-rules.json and locales.config.json — never changing code.
Two things follow from that, and they are the whole design:
- Source-language rules are shared. An English word left untranslated is a defect in every target.
forbiddenSourceTokenstherefore lives inshared, and a locale opts out of a single word only via its ownsourceTokenAllowlistwhen the word is genuinely valid in that language. - Target-language rules are per-locale. Grammar patterns, apostrophe style, canonical vocabulary, and market conventions are properties of the language and belong in its block.
Two layers, deliberately separate
Section titled “Two layers, deliberately separate”| Layer | Tool | Catches | Model needed |
|---|---|---|---|
| Deterministic gate | check_locale_quality.py | Untranslated source tokens, inconsistent renderings, banned terms, grammar patterns, ICU drift, typography, stale/empty keys | No |
| Fluency review | i18n_ai_review.py | Register, naturalness, meaning drift on individual strings | Yes (local LM Studio) |
The gate runs first and is authoritative. A model pass is a filter for what the gate cannot express — never a substitute for it, because a per-key reviewer cannot see that the same English string was translated three different ways elsewhere in the app.
Prerequisites
Section titled “Prerequisites”- Dev DB on V031 (locale columns) —
.\migration-audit.ps1 -Target Dev - Target locale
enabled: trueinfrontend/src/locales/locales.config.json - LM Studio on
http://127.0.0.1:1234(override withI18N_LMSTUDIO_BASE_URL) - Models:
qwen/qwen3.6-35b-a3b(translate),hy-mt2-30b-a3b(review; aliashymt)
Adding a new language
Section titled “Adding a new language”Everything below is driven by -Locale; nothing needs a code change.
- Add the locale to
locales.config.json.countrydecides regional conventions — it is what tells youquart de travail(Canada) fromgarde(France).nativeDisplayNamebecomes the language name in the translate and review prompts. Fillterminologyfor that market. - Add a block to
frontend/src/locales/quality-rules.json:grammarRules,bannedTerms,preferredApostrophe,allowedVariance,canonicalBySource, andsourceTokenAllowlist(usually empty). The sharedforbiddenSourceTokens/sourceMarketTokenslists apply automatically. - Runtime (language-agnostic): add the locale to
DATE_FNS_LOCALE_MAPinfrontend/src/lib/formatLocale.ts. Day strips, month headers, andterminology()must not need per-language component branches — see.cursor/rules/i18n-locale-runtime.mdc. .\scripts\run-i18n-locale-qa.ps1 -Locale <code>— runs sync, merge, parity, translate, the deterministic gate, and the AI fluency pass in order.- Fix gate findings via the rules file, then rerun
i18n_apply_locale_fixes.py. - Baseline only genuine cognates and format strings (
--update), stating why. - Smoke the switcher: chrome
t()strings and day-strip / month labels in the new language. - Native-speaker sign-off, then flip
enabled: true.
Commands
Section titled “Commands”Every script defaults its source to locales.config.json’s defaultLocale, and any script without an explicit --locale/--target acts on all enabled targets.
| Step | Command |
|---|---|
| Whole pipeline | .\scripts\run-i18n-locale-qa.ps1 -Locale fr-FR |
| Coverage | cd frontend; npm run i18n:status |
| Key / ICU parity | python backend/scripts/i18n_locale_parity.py [--target fr-FR] |
| Quality gate | python backend/scripts/check_locale_quality.py [--locale fr-FR] |
| Apply reviewed fixes | python backend/scripts/i18n_apply_locale_fixes.py [--dry-run] [--prune-stale] |
| Re-freeze baseline | python backend/scripts/check_locale_quality.py --update |
| Create namespace files | python backend/scripts/i18n_sync_locale_structure.py --target <code> |
| Fill untranslated keys | python backend/scripts/i18n_merge_source_into_locale.py --target <code> |
| Fill translations | python backend/scripts/i18n_translate_locale.py --target <code> --model qwen/qwen3.6-35b-a3b |
| AI review | python backend/scripts/i18n_ai_review.py --locale <code> --reviewers hymt --limit 500 --batch-size 4 |
| Playwright locale smoke pack | cd frontend; npm run test:e2e:i18n — switcher, chrome nav.home, day-strip month, 12h/24h config contract; auto-covers every enabled non-default locale |
The gate also runs inside .\scripts\run-quality-gates.ps1.
The rules file is the product
Section titled “The rules file is the product”frontend/src/locales/quality-rules.json holds every reviewed decision:
keyOverrides— explicit per-key corrections. Use these whenever agreement or context matters; a blanket regex over gendered nouns will produce wrong articles.canonicalBySource— one source string, one translation. This is how the consistency class is enforced.allowedVariance— source strings that should differ by context, each with a stated reason. Every entry asserts a reviewer checked it; it is not a way to silence findings.bannedTerms/grammarRules— regex plus a human-readable correction message.shiftTerm,market— the reversible regional decisions, called out so a market change is a one-line edit.shared.forbiddenSourceTokens— English words that must not survive into any bundle. Adding a word here strengthens every locale at once, which is the point of keeping it out of the per-locale blocks.
Placeholders in the source bundle must stay country-neutral for the same reason: phonePlaceholder is +XX XXX XXX XXX, not an Australian +61 4xx xxx xxx, so no locale inherits a country it does not serve.
Government schemes and bodies follow the same rule. glossary.json uses concept keys (pharmacyScheme, primaryCareDoctor); the local label lives in locales.config.json → terminology and is injected at runtime through ICU placeholders such as {scheme}. The gate’s SOURCE_MARKET check fails any target string that still contains a source-market acronym (PBS, NDIS, …) — including explanations like PBS — Australie.
Hard-won lessons (do not relearn these)
Section titled “Hard-won lessons (do not relearn these)”- Never auto-apply a model’s suggested translation to domain vocabulary. During the fr-FR pass, accepted suggestions introduced
Nuitée(a paid hotel stay) for an overnight care slot andFacile à passer(a calque) for stool ease. Both passed a placeholder-safety check because that check only validates structure, never meaning. - “0 open exceptions” is not a quality signal. Auto-triage tuned to dismiss register pedantry will also dismiss real untranslated English phrased as a register complaint.
- Batch prompts truncate. Keep
--batch-size 4; the review script salvages partial JSON and re-asks per key, but small batches avoid the problem. - A model will flag correct domain French as “too clinical.”
soins,aidant, andordonnanceare right for this product. Terminology belongs in the glossary, decided once.
One entry point — i18n_localise.py
Section titled “One entry point — i18n_localise.py”Agents and humans drive the whole pipeline through one CLI rather than reading sixteen prompt files and sequencing them by hand:
python backend/scripts/i18n_localise.py status --locale fr-FR # derived state of every steppython backend/scripts/i18n_localise.py next --locale fr-FR --json # what is runnable, and whether in parallelpython backend/scripts/i18n_localise.py task --step 21 --locale fr-FR --out task.mdpython backend/scripts/i18n_localise.py apply --step 21 --locale fr-FR --reviewed out.jsonl --reviewer gpt-5python backend/scripts/i18n_localise.py verify --locale fr-FRThree design decisions matter more than the command list:
- State is derived from artefacts, never bookkept. Whether a brief is done is answered by looking for its file; whether the catalog is localised is
itemsAwaitingLocalNamein the header. A progress file an agent must update goes stale the moment it crashes, and then lies. Derived state makesstatustrue after any interruption and every command idempotent. applyis the only verb that writes. The whole graph can be explored with no side effects.- The different-model rule is enforced, not documented.
apply --step 31refuses a reviewer already in the header’s review log, because an adversarial pass run by the model that produced the rows is theatre.
Parallel or sequential? It is a graph with three barriers, and next handles them so callers do not have to. The three briefs (10, 11, 12) are independent of each other and fan out three ways, but all must land before any content pass reads the vocabulary and unit decisions. Content passes across surfaces touch disjoint files and run concurrently, as do batches within a surface. The consistency sweep (30) is a barrier — its input is a pivot across a finished surface, so running it per batch defeats it. Sign-off is last.
Slash command in Agent chat: /i18n. Full skill (also auto-applied when relevant): .cursor/skills/localising-a-new-market/SKILL.md.
Prompt pack — opening a new language
Section titled “Prompt pack — opening a new language”backend/scripts/prompts/i18n/ holds every prompt a new market needs, in lifecycle order. They are templates: placeholders ({{LANGUAGE}}, {{MARKET}}, {{TARGET_LOCALE}}, {{COUNTRY_NAME}}) are filled from locales.config.json, so no prompt names a language. 00-house-rules.md is prepended to every model-facing prompt — register, PHI boundary, ICU placeholder safety, citation duty, no-confidence-scores, and the instruction never to reproduce a third-party clinical instrument live there once instead of drifting across sixteen files.
The organising principle is what a prompt can structurally see. A row-level reviewer cannot know the market’s labelling law; a per-key reviewer cannot see that one English word became three. So decisions are settled above the content first, content passes are split by failure mode rather than by screen, and the cross-cutting checks are separate prompts fed different inputs.
Decide once, before any content
Section titled “Decide once, before any content”| Prompt | The failure it prevents |
|---|---|
10-market-conventions-brief | Hundreds of plausible names built on unexamined legal, retail, and format assumptions |
11-domain-vocabulary-brief | Nuitée for an overnight care slot — a fluent word that changes meaning |
12-medication-naming-brief | A brand name that denotes a different active ingredient in the target market |
Content passes, one per failure mode
Section titled “Content passes, one per failure mode”| Prompt | Surface | The failure it prevents |
|---|---|---|
20-ui-strings-pass | Locale bundles | Guessed grammar on a key whose context the model could not see |
21-catalog-row-pass | catalog_items data | Literal calques; reshaped payloads that break join keys |
22-clinical-content-pass | observation_types, condition packs | Scale steps that no longer read as distinguishable, and instrument copyright breach |
23-notifications-and-messaging-pass | Push, email, in-app | Health detail on a lock screen; meaning lost to truncation |
24-marketing-and-store-listings-pass | Marketing site, store metadata | Regulated health claims; translated keywords nobody searches for |
25-legal-commercial-and-consent-brief | Terms, privacy, consent, pricing | A confident compliance assertion nobody qualified made |
Verify what no content pass can see
Section titled “Verify what no content pass can see”| Prompt | The failure it prevents |
|---|---|
30-consistency-sweep | bunch as botte in one place and bouquet in another |
31-adversarial-review | A second model politely rubber-stamping the first |
32-high-risk-audit | A dose, allergy, or emergency string that is wrong rather than awkward |
33-accessibility-audit | An accessible name that no longer contains its visible label, breaking voice control |
34-drift-top-up | New entries localised in isolation, ignoring settled decisions |
40-native-signoff-brief | A human reviewer bikeshedding register instead of checking what matters |
Surface coverage
Section titled “Surface coverage”Every user-visible surface, and what covers it. Note how much of this app’s content is rows in Postgres, not bundle strings — those surfaces need a payload and a merge step, never a namespace JSON.
| Surface | Lives in | Prompt |
|---|---|---|
| UI frame strings | frontend/src/locales/<code>/common,errors | 20 |
| Clinical UI strings | clinical.json (stub today) | 20 + 22 vocabulary |
| Notification strings | notifications.json (stub today), backend templates | 23 |
| Shopping catalog items, categories, aliases | Postgres — catalog_items, catalog_item_aliases, catalog_category_translations | 21 |
Observation types and carer-facing plain_name | Postgres — seeded by migration | 22 |
| Condition template packs, pack reason descriptions | Postgres — seeded by migration | 22 |
| Medication and pharmacy naming, prescription scan expectations | Catalog + scan module | 12 |
| Marketing site | marketing/ | 24 |
| App Store / Play listings | Store consoles | 24 |
| Terms, privacy, consent copy | Marketing + in-app | 25 |
| Pricing and billing copy | stripe_tier_local_prices, billing UI | 25 |
| Dates, numbers, currency, week start | locales.config.json + formatLocale.ts | 10 (config, not translation) |
| Names, addresses, phone formats | Form components | 10 |
| Accessible names, alt text | Alongside the visible strings | 33 |
| Emergency number, health scheme terms | locales.config.json → terminology | 10, verified by 32 |
Deliberately not localised: clinical units (mg, ml, °C) and dose values, log output, super-admin and developer tooling, migration and schema identifiers, and the product name itself.
i18n_translate_locale.py and i18n_ai_review.py build their own prompts in code for the scripted local-model path. Prompts 11 and 20 inform the glossary those scripts pass; they do not replace them.
Catalog data is a separate track (same principles)
Section titled “Catalog data is a separate track (same principles)”This harness covers UI bundle strings. Shopping-catalog product names are data — they live in catalog_items / catalog_item_aliases, not in a namespace JSON, so they never pass through check_locale_quality.py or i18n_ai_review.py.
They inherit the two structural lessons above rather than a separate philosophy:
- Shared decisions live above the row. Units are localised once in the payload header, exactly as
canonicalBySourceenforces one rendering per source string here. A per-row reviewer cannot see cross-row inconsistency. - A model’s suggestion is never auto-applied. The merge step validates structure and reports every change; a human reads the diff before it reaches the catalog.
Where it differs: a literal translation is actively wrong for retail names (EU labelling law reserves lait for dairy; a French shopper asks for Bimi, not brocolini), and a well-known local brand is an acceptable display name rather than an untranslated defect.
| Step | Command |
|---|---|
| Build / refresh payload | python backend/scripts/catalog_localisation_export.py --locale <code> [--batch-size 60] |
| Merge a reviewed file | python backend/scripts/catalog_localisation_merge.py --locale <code> --reviewed <file.jsonl> --reviewer <name> |
Policy and schema: 06-SHOPPING-MODULE.md §5 · agent rules: i18n-catalog-localisation.mdc.
Exceptions register
Section titled “Exceptions register”findings/i18n-<locale>-review-exceptions.json (e.g. i18n-fr-FR-review-exceptions.json) — output of the AI pass only, one file per locale. Statuses: open → accepted | fixed | false_positive. Treat it as a review worksheet, not a completion signal; the deterministic gate is the gate.
High-risk strings (dose, allergy, emergency) must not ship with open exceptions.
Translation and review scripts send locale keys and UI strings only — never patient or user content (doc 03 §7.8).