Skip to content

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. forbiddenSourceTokens therefore lives in shared, and a locale opts out of a single word only via its own sourceTokenAllowlist when 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.
LayerToolCatchesModel needed
Deterministic gatecheck_locale_quality.pyUntranslated source tokens, inconsistent renderings, banned terms, grammar patterns, ICU drift, typography, stale/empty keysNo
Fluency reviewi18n_ai_review.pyRegister, naturalness, meaning drift on individual stringsYes (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.

  • Dev DB on V031 (locale columns) — .\migration-audit.ps1 -Target Dev
  • Target locale enabled: true in frontend/src/locales/locales.config.json
  • LM Studio on http://127.0.0.1:1234 (override with I18N_LMSTUDIO_BASE_URL)
  • Models: qwen/qwen3.6-35b-a3b (translate), hy-mt2-30b-a3b (review; alias hymt)

Everything below is driven by -Locale; nothing needs a code change.

  1. Add the locale to locales.config.json. country decides regional conventions — it is what tells you quart de travail (Canada) from garde (France). nativeDisplayName becomes the language name in the translate and review prompts. Fill terminology for that market.
  2. Add a block to frontend/src/locales/quality-rules.json: grammarRules, bannedTerms, preferredApostrophe, allowedVariance, canonicalBySource, and sourceTokenAllowlist (usually empty). The shared forbiddenSourceTokens / sourceMarketTokens lists apply automatically.
  3. Runtime (language-agnostic): add the locale to DATE_FNS_LOCALE_MAP in frontend/src/lib/formatLocale.ts. Day strips, month headers, and terminology() must not need per-language component branches — see .cursor/rules/i18n-locale-runtime.mdc.
  4. .\scripts\run-i18n-locale-qa.ps1 -Locale <code> — runs sync, merge, parity, translate, the deterministic gate, and the AI fluency pass in order.
  5. Fix gate findings via the rules file, then rerun i18n_apply_locale_fixes.py.
  6. Baseline only genuine cognates and format strings (--update), stating why.
  7. Smoke the switcher: chrome t() strings and day-strip / month labels in the new language.
  8. Native-speaker sign-off, then flip enabled: true.

Every script defaults its source to locales.config.json’s defaultLocale, and any script without an explicit --locale/--target acts on all enabled targets.

StepCommand
Whole pipeline.\scripts\run-i18n-locale-qa.ps1 -Locale fr-FR
Coveragecd frontend; npm run i18n:status
Key / ICU paritypython backend/scripts/i18n_locale_parity.py [--target fr-FR]
Quality gatepython backend/scripts/check_locale_quality.py [--locale fr-FR]
Apply reviewed fixespython backend/scripts/i18n_apply_locale_fixes.py [--dry-run] [--prune-stale]
Re-freeze baselinepython backend/scripts/check_locale_quality.py --update
Create namespace filespython backend/scripts/i18n_sync_locale_structure.py --target <code>
Fill untranslated keyspython backend/scripts/i18n_merge_source_into_locale.py --target <code>
Fill translationspython backend/scripts/i18n_translate_locale.py --target <code> --model qwen/qwen3.6-35b-a3b
AI reviewpython backend/scripts/i18n_ai_review.py --locale <code> --reviewers hymt --limit 500 --batch-size 4
Playwright locale smoke packcd 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.

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.

  1. 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 and Facile à passer (a calque) for stool ease. Both passed a placeholder-safety check because that check only validates structure, never meaning.
  2. “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.
  3. Batch prompts truncate. Keep --batch-size 4; the review script salvages partial JSON and re-asks per key, but small batches avoid the problem.
  4. A model will flag correct domain French as “too clinical.” soins, aidant, and ordonnance are right for this product. Terminology belongs in the glossary, decided once.

Agents and humans drive the whole pipeline through one CLI rather than reading sixteen prompt files and sequencing them by hand:

Terminal window
python backend/scripts/i18n_localise.py status --locale fr-FR # derived state of every step
python backend/scripts/i18n_localise.py next --locale fr-FR --json # what is runnable, and whether in parallel
python backend/scripts/i18n_localise.py task --step 21 --locale fr-FR --out task.md
python backend/scripts/i18n_localise.py apply --step 21 --locale fr-FR --reviewed out.jsonl --reviewer gpt-5
python backend/scripts/i18n_localise.py verify --locale fr-FR

Three 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 itemsAwaitingLocalName in the header. A progress file an agent must update goes stale the moment it crashes, and then lies. Derived state makes status true after any interruption and every command idempotent.
  • apply is 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 31 refuses 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.

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.

PromptThe failure it prevents
10-market-conventions-briefHundreds of plausible names built on unexamined legal, retail, and format assumptions
11-domain-vocabulary-briefNuitée for an overnight care slot — a fluent word that changes meaning
12-medication-naming-briefA brand name that denotes a different active ingredient in the target market
PromptSurfaceThe failure it prevents
20-ui-strings-passLocale bundlesGuessed grammar on a key whose context the model could not see
21-catalog-row-passcatalog_items dataLiteral calques; reshaped payloads that break join keys
22-clinical-content-passobservation_types, condition packsScale steps that no longer read as distinguishable, and instrument copyright breach
23-notifications-and-messaging-passPush, email, in-appHealth detail on a lock screen; meaning lost to truncation
24-marketing-and-store-listings-passMarketing site, store metadataRegulated health claims; translated keywords nobody searches for
25-legal-commercial-and-consent-briefTerms, privacy, consent, pricingA confident compliance assertion nobody qualified made
PromptThe failure it prevents
30-consistency-sweepbunch as botte in one place and bouquet in another
31-adversarial-reviewA second model politely rubber-stamping the first
32-high-risk-auditA dose, allergy, or emergency string that is wrong rather than awkward
33-accessibility-auditAn accessible name that no longer contains its visible label, breaking voice control
34-drift-top-upNew entries localised in isolation, ignoring settled decisions
40-native-signoff-briefA human reviewer bikeshedding register instead of checking what matters

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.

SurfaceLives inPrompt
UI frame stringsfrontend/src/locales/<code>/common,errors20
Clinical UI stringsclinical.json (stub today)20 + 22 vocabulary
Notification stringsnotifications.json (stub today), backend templates23
Shopping catalog items, categories, aliasesPostgres — catalog_items, catalog_item_aliases, catalog_category_translations21
Observation types and carer-facing plain_namePostgres — seeded by migration22
Condition template packs, pack reason descriptionsPostgres — seeded by migration22
Medication and pharmacy naming, prescription scan expectationsCatalog + scan module12
Marketing sitemarketing/24
App Store / Play listingsStore consoles24
Terms, privacy, consent copyMarketing + in-app25
Pricing and billing copystripe_tier_local_prices, billing UI25
Dates, numbers, currency, week startlocales.config.json + formatLocale.ts10 (config, not translation)
Names, addresses, phone formatsForm components10
Accessible names, alt textAlongside the visible strings33
Emergency number, health scheme termslocales.config.json → terminology10, 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 canonicalBySource enforces 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.

StepCommand
Build / refresh payloadpython backend/scripts/catalog_localisation_export.py --locale <code> [--batch-size 60]
Merge a reviewed filepython 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.

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).