Harness i18n
Internationalization compliance verification. Detect hardcoded strings, missing translations, locale-sensitive formatting, RTL issues, and concatenation anti-patterns across web, mobile, and backend codebases.
When to Use
- Auditing new or existing codebases for i18n compliance
- Before PR merge to catch i18n regressions
- When
on_pr or on_commit triggers fire and changes touch user-facing strings
- When translation files change (missing keys, untranslated values)
- After adding a new target locale to verify coverage
- When
on_review triggers fire to validate i18n considerations
- NOT for setting up translation infrastructure (use harness-i18n-workflow)
- NOT for injecting i18n into brainstorming/planning (use harness-i18n-process)
- NOT for performing translations (use TMS tools or MCP integrations)
- NOT for non-user-facing code (internal logging, debug messages, developer tooling)
Process
Phase 1: DETECT -- Identify i18n Context
Read harness configuration. Check harness.config.json for i18n block:
i18n.enabled -- master toggle (if false or missing, run in discovery mode: detect but do not enforce)
i18n.strictness -- enforcement level (strict, standard, permissive)
i18n.sourceLocale -- BCP 47 code of source language (default: en)
i18n.targetLocales -- array of BCP 47 codes for target languages
i18n.framework -- auto or specific framework name
i18n.platforms -- which platforms to scan (web, mobile, backend)
i18n.coverage -- coverage thresholds and requirements
Auto-detect project platform(s). Scan project root for:
- Web:
package.json with React/Vue/Svelte/Next/Nuxt deps, .tsx/.jsx/.vue/.svelte files
- Mobile iOS:
*.xcodeproj, Podfile, Package.swift, .swift files
- Mobile Android:
build.gradle/build.gradle.kts, AndroidManifest.xml, .kt/.java files
- Mobile Flutter:
pubspec.yaml with flutter dependency, .dart files
- Backend:
package.json with Express/Fastify/NestJS, requirements.txt/pyproject.toml, go.mod, pom.xml/build.gradle
Auto-detect i18n framework. Read framework detection profiles from agents/skills/shared/i18n-knowledge/frameworks/. For each profile, check:
detection.package_json_keys -- dependencies and devDependencies in package.json
detection.config_files -- presence of framework config files
detection.file_patterns -- translation file patterns
- Match the first profile that satisfies detection criteria. If none match, record "no i18n framework detected."
Locate existing translation files. Search for:
- JSON files in
locales/, src/locales/, public/locales/, assets/translations/
.strings and .stringsdict files (iOS)
res/values*/strings.xml (Android)
.arb files (Flutter)
- PO/POT files (gettext)
- If
i18n.translationPaths is configured, use those paths instead.
Load locale profiles. For each locale in i18n.targetLocales (or detected from translation files), read the locale profile from agents/skills/shared/i18n-knowledge/locales/{locale}.yaml. This provides: plural rules, text direction, expansion factor, script characteristics, common pitfalls.
Load industry profile. If i18n.industry is configured, read agents/skills/shared/i18n-knowledge/industries/{industry}.yaml for industry-specific rules.
Report detection results before proceeding:
i18n Detection Report
=====================
Config: Found (i18n.enabled: true, strictness: standard)
Platform(s): web, backend
Framework: i18next (detected from package.json)
Translation files: public/locales/{en,es,fr}/*.json (3 locales, 4 namespaces)
Source locale: en
Target locales: es, fr
Industry profile: fintech (loaded)
Phase 2: SCAN -- Detect i18n Violations
Determine scan scope. Based on detected platforms, select file patterns:
- Web:
**/*.{tsx,jsx,vue,svelte,html} and **/*.{ts,js} (for template literals in rendering code)
- Mobile iOS:
**/*.swift
- Mobile Android:
**/*.{kt,java}, **/res/values*/*.xml
- Mobile Flutter:
**/*.dart
- Backend:
**/*.{ts,js,py,go,java} (filtered to HTTP handlers, templates, email services)
- Exclude:
node_modules, build, dist, .next, vendor, Pods, test files (unless explicitly included)
Scan for hardcoded user-facing strings. For each platform, apply these detection rules:
Web (React/Vue/Svelte/vanilla):
I18N-001 String literals in JSX text content (text nodes between tags)
I18N-002 String literals in i18n-sensitive props: title, placeholder, alt, aria-label, aria-description
I18N-003 Template literals with user-facing text in JSX or template expressions
- Exclude: CSS class names, data attributes, event names,
key prop, id, data-testid, className, style, type, role, htmlFor, ref, numeric literals, boolean props, import/require paths
Mobile iOS (SwiftUI/UIKit):
I18N-011 String literals in Text(), Label(), Alert(), .navigationTitle(), .toolbar labels
I18N-012 String literals in UILabel.text, UIButton.setTitle, UIAlertController messages
- Exclude: SF Symbol names, asset names, notification names, UserDefaults keys
Mobile Android (Compose/Views):
I18N-021 String literals in Text(), TextField(), Button() content
I18N-022 String literals in setText(), setTitle(), Toast.makeText()
- Exclude: Log tags, intent actions, preference keys, layout identifiers
Mobile Flutter:
I18N-031 String literals in Text(), TextSpan(), AppBar(title:), SnackBar(content:)
- Exclude: route names, asset paths, key values
Backend:
I18N-041 String literals in HTTP response bodies (res.json({ message: '...' }), res.send('...'))
I18N-042 String literals in email template content (detected via email service imports)
I18N-043 String literals in notification payloads
- Exclude: log messages (unless returned to users), internal error codes, header names, route paths
Scan for locale-sensitive formatting.
I18N-101 new Date().toLocaleDateString() without explicit locale argument
I18N-102 Number.toFixed(), .toLocaleString() without locale argument
I18N-103 Hardcoded currency symbols ($, EUR, etc.) in string templates
I18N-104 Hardcoded decimal separators (. for decimal, , for thousands)
I18N-105 new Intl.DateTimeFormat() or new Intl.NumberFormat() without locale parameter (using implicit browser locale is often a bug)
Scan for missing lang/dir attributes.
I18N-201 Missing lang attribute on <html> element
I18N-202 Missing dir attribute on <html> element (required when any target locale is RTL)
I18N-203 Missing dir="auto" on user-generated content containers (detected via heuristic: elements rendering user input, comments, messages)
I18N-204 Hardcoded left/right in CSS or style props instead of logical properties (start/end, inline-start/inline-end) -- only flagged when RTL locales are in target list
Scan for string concatenation.
I18N-301 String concatenation to build user-facing messages ("Hello, " + name, `Welcome ${name}` used as complete messages)
I18N-302 Array .join() to build sentences or messages
I18N-303 Conditional text assembly (isPlural ? "items" : "item" -- hardcoded plural logic)
- Provide framework-specific alternative in the finding (e.g., for i18next:
t('greeting', { name }))
Scan translation files for completeness.
I18N-401 Missing keys: keys present in source locale file but absent in target locale file
I18N-402 Untranslated values: values in target locale file identical to source locale (suggesting copy-paste, not translation)
I18N-403 Missing plural forms: for each locale, check that all required CLDR plural categories are present. Load plural rules from locale profile (e.g., Arabic requires: zero, one, two, few, many, other).
I18N-404 Empty translation values (key exists but value is empty string)
I18N-405 Orphan keys: keys in translation files not referenced in source code (requires cross-referencing with source scan)
Record all findings. Each finding includes:
- File path
- Line number (approximate, from Grep output)
- Violation code (e.g.,
I18N-001)
- Category:
strings, formatting, attributes, concatenation, translations
- Element or pattern that triggered the finding
- Raw evidence (the matching line of code)
Phase 3: REPORT -- Generate i18n Report
Assign severity based on i18n.strictness:
strict mode: all violations are error severity
standard mode: hardcoded strings and missing translations are error; formatting and concatenation are warn; orphan keys and info patterns are info
permissive mode: missing translations and hardcoded strings are warn; everything else is info
- Discovery mode (unconfigured): all findings are
info
Generate summary header:
i18n Report
===========
Scanned: 87 source files, 12 translation files
Findings: 24 total (8 error, 12 warn, 4 info)
Strictness: standard
Framework: i18next
Platforms: web, backend
Locales: en (source), es, fr (targets)
List findings grouped by category. Each finding follows this format:
I18N-001 [error] Hardcoded string in JSX text content
File: src/components/Header.tsx
Line: 12
Element: <h1>Welcome to our platform</h1>
Category: strings
Fix: Wrap in translation: <h1>{t('header.welcome')}</h1>
I18N-401 [error] Missing translation key
File: public/locales/es/common.json
Key: checkout.summary.totalLabel
Source: "Total" (en)
Category: translations
Fix: Add key to es/common.json with Spanish translation
Provide category summaries with counts and severity breakdown:
Category Breakdown
------------------
Strings: 12 findings (6 error, 4 warn, 2 info)
Translations: 6 findings (4 error, 2 warn)
Formatting: 3 findings (0 error, 3 warn)
Attributes: 2 findings (1 error, 1 warn)
Concatenation: 1 finding (0 error, 1 warn)
Provide translation coverage summary (if translation files exist):
Translation Coverage
--------------------
Locale Keys Translated Coverage Missing Plurals
en 142 142 100% 0
es 142 128 90.1% 2
fr 142 135 95.1% 0
If graph is available (.harness/graph/ exists): map findings to components/routes for contextual coverage. Report per-component translation coverage.
If graph is unavailable: report per-file key-level coverage. Group findings by source file.
List actionable next steps:
- Errors that can be auto-fixed (Phase 4)
- Errors that require human judgment (choosing translation keys, writing translations)
- Warnings to address in next iteration
- Coverage gaps to escalate to translation workflow (harness-i18n-workflow)
Phase 4: FIX -- Apply Automated Remediation (Optional)
This phase is optional. It applies fixes only for mechanical issues -- violations with a single, unambiguous correct fix. Translation content, key naming, and locale-specific formatting choices are never auto-fixed.
Fixable violations:
I18N-001/I18N-002: Wrap string literals in framework translation call. Detect framework from Phase 1:
- i18next:
{t('generated.key')} (generate key from string content, dot-notation)
- react-intl:
<FormattedMessage id="generated.key" defaultMessage="original text" />
- vue-i18n:
{{ $t('generated.key') }}
- No framework:
{t('generated.key')} (generic, user picks framework later)
I18N-201: Add lang="{sourceLocale}" to <html> element
I18N-202: Add dir="ltr" (or dir="auto" if RTL locales are targets) to <html> element
I18N-203: Add dir="auto" to user-content containers
I18N-404: Flag empty translation values for review (not auto-fillable)
Apply each fix as a minimal, targeted edit. Use the Edit tool. Do not refactor surrounding code. Do not change formatting. The fix should be the smallest possible change that resolves the violation.
Show before/after diff for each fix. Present the exact change to the user. This is a hard gate -- no fix is applied without showing the diff first.
Interactive confirmation per fix category. Group fixes by category (string wrapping, attribute addition) and ask for approval per category, not per individual fix:
Fix Category: String Wrapping (12 fixes)
-----------------------------------------
Wrap 12 hardcoded strings in t() calls across 5 files.
Generated keys follow dot-notation: component.element.description
Apply these fixes? [y/n]
Generate extraction output. For each wrapped string, output the key-value pair that needs to be added to the source locale translation file:
{
"header.welcome": "Welcome to our platform",
"checkout.totalLabel": "Total",
"auth.loginButton": "Sign in"
}
Re-scan after fixes. Run the scan phase again on fixed files to confirm violations are resolved. Report:
- Fixes applied: N
- Violations resolved: N
- Keys extracted: N (add to source locale file)
- Remaining violations (require human judgment): M
Do NOT fix:
- Translation content (requires human translators or TMS)
- Key naming beyond generated defaults (requires project context)
- Locale-sensitive formatting (requires knowing the correct Intl API usage for each case)
- Plural form additions (requires CLDR knowledge + framework-specific syntax)
- Any fix that would change the runtime behavior of the application
Harness Integration
harness validate -- i18n findings surface when i18n.enabled is true and i18n.strictness is strict or standard. Running validate after a scan reflects the current i18n state.
harness-integrity -- The i18n scan is chained into integrity checks when i18n.enabled: true. Findings are included in the unified integrity report.
harness-release-readiness -- Translation coverage is checked against i18n.coverage.minimumPercent. Per-locale coverage is reported.
harness-accessibility -- When both i18n and accessibility skills are enabled, lang/dir attribute checks are handled by the i18n skill. The accessibility skill defers I18N-201/202/203 to avoid duplicate findings.
harness-i18n-workflow -- After scanning, coverage gaps and extracted keys can be passed to the workflow skill for scaffolding and translation file updates.
- Knowledge base at
agents/skills/shared/i18n-knowledge/ -- Framework profiles, locale profiles, industry profiles, and anti-pattern catalogs are consumed during detect and scan phases.
Success Criteria
- All scanned source files have findings categorized by violation code and severity
- Hardcoded user-facing strings detected with correct platform-specific rules (web, mobile, backend)
- Missing translation keys and untranslated values identified with file paths and key names
- Locale-sensitive formatting issues (dates, numbers, currencies) flagged with specific file and line references
- RTL and
lang/dir attribute violations detected when target locales include RTL languages
- String concatenation and hardcoded plural logic identified as anti-patterns
- Report generated with violation codes, categories, severity, and actionable remediation
- Automated fixes applied only for mechanical issues (string wrapping, attribute addition) with interactive confirmation
- Translation coverage reported per-locale against configured thresholds
harness validate reflects i18n findings at the configured strictness level
Examples
Example: Scanning a React + i18next Project
Context: A React web app using i18next with English source, targeting Spanish and French. The harness.config.json has:
{
"version": 1,
"i18n": {
"enabled": true,
"strictness": "standard",
"sourceLocale": "en",
"targetLocales": ["es", "fr"],
"framework": "auto",
"platforms": ["web"]
}
}
Phase 1: DETECT
i18n Detection Report
=====================
Config: Found (i18n.enabled: true, strictness: standard)
Platform(s): web
Framework: i18next (detected from package.json: "i18next", "react-i18next")
Translation files: public/locales/{en,es,fr}/common.json (3 locales, 1 namespace)
Source locale: en
Target locales: es, fr
Industry profile: none configured
Phase 2: SCAN
Source file with violations:
// src/components/CheckoutSummary.tsx
export function CheckoutSummary({ items, total }) {
return (
<div>
<h2>Order Summary</h2>
<p>
You have {items.length} {items.length === 1 ? 'item' : 'items'} in your cart.
</p>
<span title="Total price">Total: ${total.toFixed(2)}</span>
</div>
);
}
Findings:
I18N-001 [error] Hardcoded string in JSX text content
File: src/components/CheckoutSummary.tsx
Line: 5
Element: <h2>Order Summary</h2>
Category: strings
Fix: Wrap in translation: <h2>{t('checkout.orderSummary')}</h2>
I18N-002 [error] Hardcoded string in i18n-sensitive prop
File: src/components/CheckoutSummary.tsx
Line: 9
Element: title="Total price"
Category: strings
Fix: Wrap in translation: title={t('checkout.totalPriceTitle')}
I18N-303 [warn] Conditional text assembly (hardcoded plural logic)
File: src/components/CheckoutSummary.tsx
Line: 7
Element: items.length === 1 ? "item" : "items"
Category: concatenation
Fix: Use i18next plural: t('checkout.itemCount', { count: items.length })
I18N-103 [warn] Hardcoded currency symbol
File: src/components/CheckoutSummary.tsx
Line: 10
Element: $${total.toFixed(2)}
Category: formatting
Fix: Use Intl.NumberFormat: new Intl.NumberFormat(locale, { style: 'currency', currency }).format(total)
I18N-102 [warn] Number.toFixed() without locale-aware formatting
File: src/components/CheckoutSummary.tsx
Line: 10
Element: total.toFixed(2)
Category: formatting
Fix: Use Intl.NumberFormat for locale-aware decimal formatting
Translation file issue:
I18N-401 [error] Missing translation key
File: public/locales/es/common.json
Key: checkout.confirmButton
Source: "Confirm Order" (en)
Category: translations
Fix: Add key to es/common.json with Spanish translation
I18N-402 [warn] Untranslated value (identical to source)
File: public/locales/fr/common.json
Key: auth.welcomeMessage
Source: "Welcome back" (en)
Value: "Welcome back" (fr -- same as source, likely untranslated)
Category: translations
Fix: Translate value to French or mark as intentionally identical
Phase 3: REPORT
i18n Report
===========
Scanned: 23 source files, 6 translation files
Findings: 7 total (3 error, 3 warn, 1 info)
Strictness: standard
Framework: i18next
Platforms: web
Locales: en (source), es, fr (targets)
Category Breakdown
------------------
Strings: 2 findings (2 error, 0 warn)
Translations: 2 findings (1 error, 1 warn)
Formatting: 2 findings (0 error, 2 warn)
Concatenation: 1 finding (0 error, 1 warn)
Translation Coverage
--------------------
Locale Keys Translated Coverage Missing Plurals
en 42 42 100% 0
es 42 41 97.6% 0
fr 42 42 100% 0
(note: fr has 1 untranslated value not counted as missing)
Phase 4: FIX
Fix Category: String Wrapping (2 fixes)
-----------------------------------------
Wrap 2 hardcoded strings in t() calls in CheckoutSummary.tsx.
Generated keys: checkout.orderSummary, checkout.totalPriceTitle
Apply these fixes? [y/n]
After applying fixes:
- <h2>Order Summary</h2>
+ <h2>{t('checkout.orderSummary')}</h2>
- <span title="Total price">
+ <span title={t('checkout.totalPriceTitle')}>
Keys extracted for source locale file:
{
"checkout.orderSummary": "Order Summary",
"checkout.totalPriceTitle": "Total price"
}
Remaining violations (require human judgment): 5
- I18N-303: Plural logic -- requires choosing i18next plural key structure
- I18N-103: Currency symbol -- requires knowing the correct currency code per locale
- I18N-102: Number formatting -- requires choosing Intl.NumberFormat options
- I18N-401: Missing key in es -- requires Spanish translation
- I18N-402: Untranslated value in fr -- requires French translation
Rationalizations to Reject
| Rationalization |
Reality |
| "This string is the app's brand name — it's technically hardcoded but obviously shouldn't be translated. I'll skip flagging it." |
Brand names require explicit suppression via // i18n-ignore comment, not silent omission from the scan. Skipping without suppression means future scans have inconsistent results and the team has no record of the deliberate decision. |
| "The framework isn't in the knowledge base, but I can tell from context it's using i18next patterns — I'll apply i18next rules directly." |
Unrecognized frameworks must fall back to generic detection rules, not assumed framework rules. Applying i18next-specific fix patterns to an unknown framework produces incorrect wrapping that breaks at runtime. Log the gap and use generic rules. |
"The project has i18n.enabled: false — I'll still flag errors for hardcoded strings since the team should know about them." |
Respecting i18n.enabled: false is a gate. The team made a configuration decision. In that state, run in discovery mode (info severity only). Escalating to errors overrides the team's explicit choice. |
| "I18N-402 untranslated values are just warnings — I'll skip reporting them to keep the report shorter." |
Untranslated values (target identical to source) are a distinct violation category with their own code. They indicate copy-paste during file creation without actual translation. Omitting them produces a misleadingly optimistic coverage report. |
| "The plural rules for this locale look complex — I'll just check for 'one' and 'other' forms like English and move on." |
Plural rules are locale-specific and must be loaded from the locale profile. Arabic requires six categories; Polish requires four. Checking only English plural categories produces false-passing results for languages that require more forms. |
Gates
These are hard stops. Violating any gate means the process has broken down.
- No scan results without completing the detect phase first. Framework and platform detection must run before scanning begins.
- No fix applied without showing the before/after diff. Every fix must be presented to the user with the exact code change before being written to disk.
- No severity downgrade below what
i18n.strictness specifies. If the project is in strict mode, a hardcoded string is an error. The scanner does not get to decide it is a warning.
- No translation content generated by the fix phase. The fix phase wraps strings and adds attributes. It does not write translations. Translation content is the domain of humans or TMS tools.
- No false-positive suppression without explicit user confirmation. If a string is intentionally not translated (e.g., brand name), the user must mark it with a suppression comment (
// i18n-ignore) before it is excluded from future scans.
Escalation
- When a project has more than 100 hardcoded strings: suggest running harness-i18n-workflow for bulk extraction and scaffolding rather than fixing one by one.
- When no i18n framework is detected: recommend one based on the project platform (i18next for React/Node, vue-i18n for Vue, flutter intl for Flutter, etc.). Reference the framework profiles in the knowledge base.
- When translation coverage is below 50%: suggest a phased approach -- prioritize user-facing flows (checkout, onboarding, error messages) before attempting full coverage.
- When target locales include RTL languages (ar, he) and the project has no RTL support: flag this as a high-priority architectural concern. RTL support often requires layout changes beyond simple attribute additions.
- When the project uses a framework not in the knowledge base: fall back to generic detection rules. Log: "Framework {name} not in knowledge base -- using generic string detection. Consider contributing a framework profile."
1---2name: harness-i18n3description: Harness i18n4metadata:5 source: https://skillmd.com/skills/intense-visions/harness-i18n6---7# Harness i18n89> Internationalization compliance verification. Detect hardcoded strings, missing translations, locale-sensitive formatting, RTL issues, and concatenation anti-patterns across web, mobile, and backend codebases.1011## When to Use1213- Auditing new or existing codebases for i18n compliance14- Before PR merge to catch i18n regressions15- When `on_pr` or `on_commit` triggers fire and changes touch user-facing strings16- When translation files change (missing keys, untranslated values)17- After adding a new target locale to verify coverage18- When `on_review` triggers fire to validate i18n considerations19- NOT for setting up translation infrastructure (use harness-i18n-workflow)20- NOT for injecting i18n into brainstorming/planning (use harness-i18n-process)21- NOT for performing translations (use TMS tools or MCP integrations)22- NOT for non-user-facing code (internal logging, debug messages, developer tooling)2324## Process2526### Phase 1: DETECT -- Identify i18n Context27281. **Read harness configuration.** Check `harness.config.json` for `i18n` block:29 - `i18n.enabled` -- master toggle (if false or missing, run in discovery mode: detect but do not enforce)30 - `i18n.strictness` -- enforcement level (`strict`, `standard`, `permissive`)31 - `i18n.sourceLocale` -- BCP 47 code of source language (default: `en`)32 - `i18n.targetLocales` -- array of BCP 47 codes for target languages33 - `i18n.framework` -- `auto` or specific framework name34 - `i18n.platforms` -- which platforms to scan (`web`, `mobile`, `backend`)35 - `i18n.coverage` -- coverage thresholds and requirements36372. **Auto-detect project platform(s).** Scan project root for:38 - Web: `package.json` with React/Vue/Svelte/Next/Nuxt deps, `.tsx`/`.jsx`/`.vue`/`.svelte` files39 - Mobile iOS: `*.xcodeproj`, `Podfile`, `Package.swift`, `.swift` files40 - Mobile Android: `build.gradle`/`build.gradle.kts`, `AndroidManifest.xml`, `.kt`/`.java` files41 - Mobile Flutter: `pubspec.yaml` with `flutter` dependency, `.dart` files42 - Backend: `package.json` with Express/Fastify/NestJS, `requirements.txt`/`pyproject.toml`, `go.mod`, `pom.xml`/`build.gradle`43443. **Auto-detect i18n framework.** Read framework detection profiles from `agents/skills/shared/i18n-knowledge/frameworks/`. For each profile, check:45 - `detection.package_json_keys` -- dependencies and devDependencies in `package.json`46 - `detection.config_files` -- presence of framework config files47 - `detection.file_patterns` -- translation file patterns48 - Match the first profile that satisfies detection criteria. If none match, record "no i18n framework detected."49504. **Locate existing translation files.** Search for:51 - JSON files in `locales/`, `src/locales/`, `public/locales/`, `assets/translations/`52 - `.strings` and `.stringsdict` files (iOS)53 - `res/values*/strings.xml` (Android)54 - `.arb` files (Flutter)55 - PO/POT files (gettext)56 - If `i18n.translationPaths` is configured, use those paths instead.57585. **Load locale profiles.** For each locale in `i18n.targetLocales` (or detected from translation files), read the locale profile from `agents/skills/shared/i18n-knowledge/locales/{locale}.yaml`. This provides: plural rules, text direction, expansion factor, script characteristics, common pitfalls.59606. **Load industry profile.** If `i18n.industry` is configured, read `agents/skills/shared/i18n-knowledge/industries/{industry}.yaml` for industry-specific rules.61627. **Report detection results before proceeding:**6364 ```65 i18n Detection Report66 =====================67 Config: Found (i18n.enabled: true, strictness: standard)68 Platform(s): web, backend69 Framework: i18next (detected from package.json)70 Translation files: public/locales/{en,es,fr}/*.json (3 locales, 4 namespaces)71 Source locale: en72 Target locales: es, fr73 Industry profile: fintech (loaded)74 ```7576### Phase 2: SCAN -- Detect i18n Violations77781. **Determine scan scope.** Based on detected platforms, select file patterns:79 - Web: `**/*.{tsx,jsx,vue,svelte,html}` and `**/*.{ts,js}` (for template literals in rendering code)80 - Mobile iOS: `**/*.swift`81 - Mobile Android: `**/*.{kt,java}`, `**/res/values*/*.xml`82 - Mobile Flutter: `**/*.dart`83 - Backend: `**/*.{ts,js,py,go,java}` (filtered to HTTP handlers, templates, email services)84 - Exclude: `node_modules`, `build`, `dist`, `.next`, `vendor`, `Pods`, test files (unless explicitly included)85862. **Scan for hardcoded user-facing strings.** For each platform, apply these detection rules:8788 _Web (React/Vue/Svelte/vanilla):_89 - `I18N-001` String literals in JSX text content (text nodes between tags)90 - `I18N-002` String literals in i18n-sensitive props: `title`, `placeholder`, `alt`, `aria-label`, `aria-description`91 - `I18N-003` Template literals with user-facing text in JSX or template expressions92 - Exclude: CSS class names, data attributes, event names, `key` prop, `id`, `data-testid`, `className`, `style`, `type`, `role`, `htmlFor`, `ref`, numeric literals, boolean props, import/require paths9394 _Mobile iOS (SwiftUI/UIKit):_95 - `I18N-011` String literals in `Text()`, `Label()`, `Alert()`, `.navigationTitle()`, `.toolbar` labels96 - `I18N-012` String literals in `UILabel.text`, `UIButton.setTitle`, `UIAlertController` messages97 - Exclude: SF Symbol names, asset names, notification names, UserDefaults keys9899 _Mobile Android (Compose/Views):_100 - `I18N-021` String literals in `Text()`, `TextField()`, `Button()` content101 - `I18N-022` String literals in `setText()`, `setTitle()`, `Toast.makeText()`102 - Exclude: Log tags, intent actions, preference keys, layout identifiers103104 _Mobile Flutter:_105 - `I18N-031` String literals in `Text()`, `TextSpan()`, `AppBar(title:)`, `SnackBar(content:)`106 - Exclude: route names, asset paths, key values107108 _Backend:_109 - `I18N-041` String literals in HTTP response bodies (`res.json({ message: '...' })`, `res.send('...')`)110 - `I18N-042` String literals in email template content (detected via email service imports)111 - `I18N-043` String literals in notification payloads112 - Exclude: log messages (unless returned to users), internal error codes, header names, route paths1131143. **Scan for locale-sensitive formatting.**115 - `I18N-101` `new Date().toLocaleDateString()` without explicit locale argument116 - `I18N-102` `Number.toFixed()`, `.toLocaleString()` without locale argument117 - `I18N-103` Hardcoded currency symbols (`$`, `EUR`, etc.) in string templates118 - `I18N-104` Hardcoded decimal separators (`.` for decimal, `,` for thousands)119 - `I18N-105` `new Intl.DateTimeFormat()` or `new Intl.NumberFormat()` without locale parameter (using implicit browser locale is often a bug)1201214. **Scan for missing `lang`/`dir` attributes.**122 - `I18N-201` Missing `lang` attribute on `<html>` element123 - `I18N-202` Missing `dir` attribute on `<html>` element (required when any target locale is RTL)124 - `I18N-203` Missing `dir="auto"` on user-generated content containers (detected via heuristic: elements rendering user input, comments, messages)125 - `I18N-204` Hardcoded `left`/`right` in CSS or style props instead of logical properties (`start`/`end`, `inline-start`/`inline-end`) -- only flagged when RTL locales are in target list1261275. **Scan for string concatenation.**128 - `I18N-301` String concatenation to build user-facing messages (`"Hello, " + name`, `` `Welcome ${name}` `` used as complete messages)129 - `I18N-302` Array `.join()` to build sentences or messages130 - `I18N-303` Conditional text assembly (`isPlural ? "items" : "item"` -- hardcoded plural logic)131 - Provide framework-specific alternative in the finding (e.g., for i18next: `t('greeting', { name })`)1321336. **Scan translation files for completeness.**134 - `I18N-401` Missing keys: keys present in source locale file but absent in target locale file135 - `I18N-402` Untranslated values: values in target locale file identical to source locale (suggesting copy-paste, not translation)136 - `I18N-403` Missing plural forms: for each locale, check that all required CLDR plural categories are present. Load plural rules from locale profile (e.g., Arabic requires: zero, one, two, few, many, other).137 - `I18N-404` Empty translation values (key exists but value is empty string)138 - `I18N-405` Orphan keys: keys in translation files not referenced in source code (requires cross-referencing with source scan)1391407. **Record all findings.** Each finding includes:141 - File path142 - Line number (approximate, from Grep output)143 - Violation code (e.g., `I18N-001`)144 - Category: `strings`, `formatting`, `attributes`, `concatenation`, `translations`145 - Element or pattern that triggered the finding146 - Raw evidence (the matching line of code)147148### Phase 3: REPORT -- Generate i18n Report1491501. **Assign severity based on `i18n.strictness`:**151 - `strict` mode: all violations are `error` severity152 - `standard` mode: hardcoded strings and missing translations are `error`; formatting and concatenation are `warn`; orphan keys and info patterns are `info`153 - `permissive` mode: missing translations and hardcoded strings are `warn`; everything else is `info`154 - Discovery mode (unconfigured): all findings are `info`1551562. **Generate summary header:**157158 ```159 i18n Report160 ===========161 Scanned: 87 source files, 12 translation files162 Findings: 24 total (8 error, 12 warn, 4 info)163 Strictness: standard164 Framework: i18next165 Platforms: web, backend166 Locales: en (source), es, fr (targets)167 ```1681693. **List findings grouped by category.** Each finding follows this format:170171 ```172 I18N-001 [error] Hardcoded string in JSX text content173 File: src/components/Header.tsx174 Line: 12175 Element: <h1>Welcome to our platform</h1>176 Category: strings177 Fix: Wrap in translation: <h1>{t('header.welcome')}</h1>178 ```179180 ```181 I18N-401 [error] Missing translation key182 File: public/locales/es/common.json183 Key: checkout.summary.totalLabel184 Source: "Total" (en)185 Category: translations186 Fix: Add key to es/common.json with Spanish translation187 ```1881894. **Provide category summaries** with counts and severity breakdown:190191 ```192 Category Breakdown193 ------------------194 Strings: 12 findings (6 error, 4 warn, 2 info)195 Translations: 6 findings (4 error, 2 warn)196 Formatting: 3 findings (0 error, 3 warn)197 Attributes: 2 findings (1 error, 1 warn)198 Concatenation: 1 finding (0 error, 1 warn)199 ```2002015. **Provide translation coverage summary** (if translation files exist):202203 ```204 Translation Coverage205 --------------------206 Locale Keys Translated Coverage Missing Plurals207 en 142 142 100% 0208 es 142 128 90.1% 2209 fr 142 135 95.1% 0210 ```2112126. **If graph is available** (`.harness/graph/` exists): map findings to components/routes for contextual coverage. Report per-component translation coverage.2132147. **If graph is unavailable**: report per-file key-level coverage. Group findings by source file.2152168. **List actionable next steps:**217 - Errors that can be auto-fixed (Phase 4)218 - Errors that require human judgment (choosing translation keys, writing translations)219 - Warnings to address in next iteration220 - Coverage gaps to escalate to translation workflow (harness-i18n-workflow)221222### Phase 4: FIX -- Apply Automated Remediation (Optional)223224This phase is optional. It applies fixes only for mechanical issues -- violations with a single, unambiguous correct fix. Translation content, key naming, and locale-specific formatting choices are never auto-fixed.2252261. **Fixable violations:**227 - `I18N-001`/`I18N-002`: Wrap string literals in framework translation call. Detect framework from Phase 1:228 - i18next: `{t('generated.key')}` (generate key from string content, dot-notation)229 - react-intl: `<FormattedMessage id="generated.key" defaultMessage="original text" />`230 - vue-i18n: `{{ $t('generated.key') }}`231 - No framework: `{t('generated.key')}` (generic, user picks framework later)232 - `I18N-201`: Add `lang="{sourceLocale}"` to `<html>` element233 - `I18N-202`: Add `dir="ltr"` (or `dir="auto"` if RTL locales are targets) to `<html>` element234 - `I18N-203`: Add `dir="auto"` to user-content containers235 - `I18N-404`: Flag empty translation values for review (not auto-fillable)2362372. **Apply each fix as a minimal, targeted edit.** Use the Edit tool. Do not refactor surrounding code. Do not change formatting. The fix should be the smallest possible change that resolves the violation.2382393. **Show before/after diff for each fix.** Present the exact change to the user. This is a hard gate -- no fix is applied without showing the diff first.2402414. **Interactive confirmation per fix category.** Group fixes by category (string wrapping, attribute addition) and ask for approval per category, not per individual fix:242243 ```244 Fix Category: String Wrapping (12 fixes)245 -----------------------------------------246 Wrap 12 hardcoded strings in t() calls across 5 files.247 Generated keys follow dot-notation: component.element.description248249 Apply these fixes? [y/n]250 ```2512525. **Generate extraction output.** For each wrapped string, output the key-value pair that needs to be added to the source locale translation file:253254 ```json255 {256 "header.welcome": "Welcome to our platform",257 "checkout.totalLabel": "Total",258 "auth.loginButton": "Sign in"259 }260 ```2612626. **Re-scan after fixes.** Run the scan phase again on fixed files to confirm violations are resolved. Report:263 - Fixes applied: N264 - Violations resolved: N265 - Keys extracted: N (add to source locale file)266 - Remaining violations (require human judgment): M2672687. **Do NOT fix:**269 - Translation content (requires human translators or TMS)270 - Key naming beyond generated defaults (requires project context)271 - Locale-sensitive formatting (requires knowing the correct Intl API usage for each case)272 - Plural form additions (requires CLDR knowledge + framework-specific syntax)273 - Any fix that would change the runtime behavior of the application274275## Harness Integration276277- **`harness validate`** -- i18n findings surface when `i18n.enabled` is true and `i18n.strictness` is `strict` or `standard`. Running validate after a scan reflects the current i18n state.278- **`harness-integrity`** -- The i18n scan is chained into integrity checks when `i18n.enabled: true`. Findings are included in the unified integrity report.279- **`harness-release-readiness`** -- Translation coverage is checked against `i18n.coverage.minimumPercent`. Per-locale coverage is reported.280- **`harness-accessibility`** -- When both i18n and accessibility skills are enabled, `lang`/`dir` attribute checks are handled by the i18n skill. The accessibility skill defers I18N-201/202/203 to avoid duplicate findings.281- **`harness-i18n-workflow`** -- After scanning, coverage gaps and extracted keys can be passed to the workflow skill for scaffolding and translation file updates.282- **Knowledge base** at `agents/skills/shared/i18n-knowledge/` -- Framework profiles, locale profiles, industry profiles, and anti-pattern catalogs are consumed during detect and scan phases.283284## Success Criteria285286- All scanned source files have findings categorized by violation code and severity287- Hardcoded user-facing strings detected with correct platform-specific rules (web, mobile, backend)288- Missing translation keys and untranslated values identified with file paths and key names289- Locale-sensitive formatting issues (dates, numbers, currencies) flagged with specific file and line references290- RTL and `lang`/`dir` attribute violations detected when target locales include RTL languages291- String concatenation and hardcoded plural logic identified as anti-patterns292- Report generated with violation codes, categories, severity, and actionable remediation293- Automated fixes applied only for mechanical issues (string wrapping, attribute addition) with interactive confirmation294- Translation coverage reported per-locale against configured thresholds295- `harness validate` reflects i18n findings at the configured strictness level296297## Examples298299### Example: Scanning a React + i18next Project300301**Context:** A React web app using i18next with English source, targeting Spanish and French. The `harness.config.json` has:302303```json304{305 "version": 1,306 "i18n": {307 "enabled": true,308 "strictness": "standard",309 "sourceLocale": "en",310 "targetLocales": ["es", "fr"],311 "framework": "auto",312 "platforms": ["web"]313 }314}315```316317**Phase 1: DETECT**318319```320i18n Detection Report321=====================322Config: Found (i18n.enabled: true, strictness: standard)323Platform(s): web324Framework: i18next (detected from package.json: "i18next", "react-i18next")325Translation files: public/locales/{en,es,fr}/common.json (3 locales, 1 namespace)326Source locale: en327Target locales: es, fr328Industry profile: none configured329```330331**Phase 2: SCAN**332333Source file with violations:334335```tsx336// src/components/CheckoutSummary.tsx337export function CheckoutSummary({ items, total }) {338 return (339 <div>340 <h2>Order Summary</h2>341 <p>342 You have {items.length} {items.length === 1 ? 'item' : 'items'} in your cart.343 </p>344 <span title="Total price">Total: ${total.toFixed(2)}</span>345 </div>346 );347}348```349350Findings:351352```353I18N-001 [error] Hardcoded string in JSX text content354 File: src/components/CheckoutSummary.tsx355 Line: 5356 Element: <h2>Order Summary</h2>357 Category: strings358 Fix: Wrap in translation: <h2>{t('checkout.orderSummary')}</h2>359360I18N-002 [error] Hardcoded string in i18n-sensitive prop361 File: src/components/CheckoutSummary.tsx362 Line: 9363 Element: title="Total price"364 Category: strings365 Fix: Wrap in translation: title={t('checkout.totalPriceTitle')}366367I18N-303 [warn] Conditional text assembly (hardcoded plural logic)368 File: src/components/CheckoutSummary.tsx369 Line: 7370 Element: items.length === 1 ? "item" : "items"371 Category: concatenation372 Fix: Use i18next plural: t('checkout.itemCount', { count: items.length })373374I18N-103 [warn] Hardcoded currency symbol375 File: src/components/CheckoutSummary.tsx376 Line: 10377 Element: $${total.toFixed(2)}378 Category: formatting379 Fix: Use Intl.NumberFormat: new Intl.NumberFormat(locale, { style: 'currency', currency }).format(total)380381I18N-102 [warn] Number.toFixed() without locale-aware formatting382 File: src/components/CheckoutSummary.tsx383 Line: 10384 Element: total.toFixed(2)385 Category: formatting386 Fix: Use Intl.NumberFormat for locale-aware decimal formatting387```388389Translation file issue:390391```392I18N-401 [error] Missing translation key393 File: public/locales/es/common.json394 Key: checkout.confirmButton395 Source: "Confirm Order" (en)396 Category: translations397 Fix: Add key to es/common.json with Spanish translation398399I18N-402 [warn] Untranslated value (identical to source)400 File: public/locales/fr/common.json401 Key: auth.welcomeMessage402 Source: "Welcome back" (en)403 Value: "Welcome back" (fr -- same as source, likely untranslated)404 Category: translations405 Fix: Translate value to French or mark as intentionally identical406```407408**Phase 3: REPORT**409410```411i18n Report412===========413Scanned: 23 source files, 6 translation files414Findings: 7 total (3 error, 3 warn, 1 info)415Strictness: standard416Framework: i18next417Platforms: web418Locales: en (source), es, fr (targets)419420Category Breakdown421------------------422Strings: 2 findings (2 error, 0 warn)423Translations: 2 findings (1 error, 1 warn)424Formatting: 2 findings (0 error, 2 warn)425Concatenation: 1 finding (0 error, 1 warn)426427Translation Coverage428--------------------429Locale Keys Translated Coverage Missing Plurals430en 42 42 100% 0431es 42 41 97.6% 0432fr 42 42 100% 0433(note: fr has 1 untranslated value not counted as missing)434```435436**Phase 4: FIX**437438```439Fix Category: String Wrapping (2 fixes)440-----------------------------------------441Wrap 2 hardcoded strings in t() calls in CheckoutSummary.tsx.442Generated keys: checkout.orderSummary, checkout.totalPriceTitle443444Apply these fixes? [y/n]445```446447After applying fixes:448449```diff450- <h2>Order Summary</h2>451+ <h2>{t('checkout.orderSummary')}</h2>452453- <span title="Total price">454+ <span title={t('checkout.totalPriceTitle')}>455```456457Keys extracted for source locale file:458459```json460{461 "checkout.orderSummary": "Order Summary",462 "checkout.totalPriceTitle": "Total price"463}464```465466Remaining violations (require human judgment): 5467468- I18N-303: Plural logic -- requires choosing i18next plural key structure469- I18N-103: Currency symbol -- requires knowing the correct currency code per locale470- I18N-102: Number formatting -- requires choosing Intl.NumberFormat options471- I18N-401: Missing key in es -- requires Spanish translation472- I18N-402: Untranslated value in fr -- requires French translation473474## Rationalizations to Reject475476| Rationalization | Reality |477| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |478| "This string is the app's brand name — it's technically hardcoded but obviously shouldn't be translated. I'll skip flagging it." | Brand names require explicit suppression via `// i18n-ignore` comment, not silent omission from the scan. Skipping without suppression means future scans have inconsistent results and the team has no record of the deliberate decision. |479| "The framework isn't in the knowledge base, but I can tell from context it's using i18next patterns — I'll apply i18next rules directly." | Unrecognized frameworks must fall back to generic detection rules, not assumed framework rules. Applying i18next-specific fix patterns to an unknown framework produces incorrect wrapping that breaks at runtime. Log the gap and use generic rules. |480| "The project has `i18n.enabled: false` — I'll still flag errors for hardcoded strings since the team should know about them." | Respecting `i18n.enabled: false` is a gate. The team made a configuration decision. In that state, run in discovery mode (info severity only). Escalating to errors overrides the team's explicit choice. |481| "I18N-402 untranslated values are just warnings — I'll skip reporting them to keep the report shorter." | Untranslated values (target identical to source) are a distinct violation category with their own code. They indicate copy-paste during file creation without actual translation. Omitting them produces a misleadingly optimistic coverage report. |482| "The plural rules for this locale look complex — I'll just check for 'one' and 'other' forms like English and move on." | Plural rules are locale-specific and must be loaded from the locale profile. Arabic requires six categories; Polish requires four. Checking only English plural categories produces false-passing results for languages that require more forms. |483484## Gates485486These are hard stops. Violating any gate means the process has broken down.487488- **No scan results without completing the detect phase first.** Framework and platform detection must run before scanning begins.489- **No fix applied without showing the before/after diff.** Every fix must be presented to the user with the exact code change before being written to disk.490- **No severity downgrade below what `i18n.strictness` specifies.** If the project is in `strict` mode, a hardcoded string is an error. The scanner does not get to decide it is a warning.491- **No translation content generated by the fix phase.** The fix phase wraps strings and adds attributes. It does not write translations. Translation content is the domain of humans or TMS tools.492- **No false-positive suppression without explicit user confirmation.** If a string is intentionally not translated (e.g., brand name), the user must mark it with a suppression comment (`// i18n-ignore`) before it is excluded from future scans.493494## Escalation495496- **When a project has more than 100 hardcoded strings:** suggest running harness-i18n-workflow for bulk extraction and scaffolding rather than fixing one by one.497- **When no i18n framework is detected:** recommend one based on the project platform (i18next for React/Node, vue-i18n for Vue, flutter intl for Flutter, etc.). Reference the framework profiles in the knowledge base.498- **When translation coverage is below 50%:** suggest a phased approach -- prioritize user-facing flows (checkout, onboarding, error messages) before attempting full coverage.499- **When target locales include RTL languages (ar, he) and the project has no RTL support:** flag this as a high-priority architectural concern. RTL support often requires layout changes beyond simple attribute additions.500- **When the project uses a framework not in the knowledge base:** fall back to generic detection rules. Log: "Framework {name} not in knowledge base -- using generic string detection. Consider contributing a framework profile."