Using AI for Internationalization: Extract, Translate, and Maintain i18n Files
A practical guide to using AI coding assistants to extract hardcoded strings, generate translation files, detect coverage gaps, and keep i18n in sync as your app evolves.
Internationalization is one of those tasks developers put off until it becomes painful. By then you have hundreds of hardcoded strings scattered through the codebase, no consistent key naming scheme, and a pile of translation debt. AI assistants are genuinely useful here — not to replace human translators, but to handle the mechanical parts that make i18n feel tedious: extraction, key generation, coverage auditing, and keeping translations in sync as the UI evolves.
What AI is and isn’t good at here
Before diving in, it’s worth being clear about where AI helps and where it doesn’t.
Where AI is effective:
- Extracting hardcoded strings from existing components
- Generating consistent translation key names from string content
- Writing the boilerplate structure of locale files
- Detecting gaps between locales (keys present in one file but missing from another)
- Writing plausible first-draft translations for common languages in low-ambiguity contexts
Where AI falls short:
- Marketing copy or brand voice that needs a native speaker
- Locale-specific cultural nuance — tone, formality registers, regional idiom
- Languages with complex plural forms, grammatical gender, or agglutination without careful prompting
Use AI as a first draft and a maintenance tool. Final review by a native speaker still matters for user-facing text in languages you’re shipping to real audiences.
Step 1: Auditing for hardcoded strings
The first step is knowing what you have. Rather than reading every file manually, ask the AI to do a targeted scan:
Read the components in src/components/ and src/pages/. List every hardcoded
user-visible string — button labels, error messages, placeholder text,
aria-labels, empty state copy — along with the file path and line number.
Exclude:
- Developer-facing strings (console.log output, error messages used only in monitoring)
- CSS class names and HTML attributes that are not user-visible
- Strings already wrapped in a t() call or similar i18n function
Output as a table: | File | Line | String |
This gives you a complete inventory before you change anything. For large codebases, run it directory by directory rather than across the whole tree — the output stays manageable and the model stays more accurate with a tighter scope.
Step 2: Generating a translation key structure
With the string inventory in hand, design the key namespace. Consistency matters here: a flat list of keys grows unmanageable quickly, and AI can apply a naming convention across the whole inventory in one pass:
Here is a list of hardcoded strings from our React app:
| File | String |
|------|--------|
| src/pages/Login.tsx | "Sign in to your account" |
| src/pages/Login.tsx | "Email address" |
| src/pages/Login.tsx | "Forgot your password?" |
| src/components/EmptyState.tsx | "No results found" |
| src/components/EmptyState.tsx | "Try adjusting your filters" |
Create a JSON translation file (en.json) for these strings. Use dot-separated
namespace keys: page.sectionOrComponent.descriptiveKey. For example:
"login.heading", "login.form.emailLabel", "login.form.forgotPassword".
Name keys by semantic purpose, not content — so if the string changes,
the key still makes sense.
The result is an en.json with consistent structure you can use as the base for all other locales.
Step 3: Replacing hardcoded strings in components
With the key map defined, replace the hardcoded strings one component at a time. Working component by component keeps the task bounded and makes review easier:
Refactor src/pages/Login.tsx to use the i18n keys we defined. Import the
useTranslation hook from react-i18next. Replace hardcoded strings with
t('login.heading'), t('login.form.emailLabel'), etc., using the keys in en.json.
Do not change any logic, component structure, or prop types — only the
string literals and the import.
The final constraint matters. i18n extraction tasks have a scope-creep problem: the model notices other things it could “improve” while it’s in the file. That single instruction — “only the strings and the import” — prevents most of it. For more on keeping agents in scope, see Steering a Drifting AI Agent.
Step 4: Generating translations for other locales
With en.json as the source of truth, generating a first-draft locale file is straightforward:
Here is our English locale file:
[paste en.json]
Generate a Spanish (es.json) translation. Keep the JSON structure and all
keys identical. Translate only the values.
If a string includes a placeholder (e.g. {{name}}, {count}), preserve the
placeholder exactly as written — do not translate it.
If you're uncertain about a translation, translate it anyway and add a
companion key "originalKey__review": true so we can filter and revisit
those entries before shipping.
The placeholder preservation instruction is essential — models occasionally translate {{name}} to something locale-appropriate that breaks interpolation at runtime. Making it explicit prevents the most common breakage.
The __review flag convention lets you post-process the file with a simple grep to find strings that need a human check, without losing the initial draft.
Step 5: Detecting coverage gaps
As the app evolves, en.json grows and translation files fall behind. AI can audit the coverage gap quickly:
Compare these two files:
en.json (source of truth):
[paste en.json]
fr.json (French translation):
[paste fr.json]
Report:
1. Keys present in en.json but missing from fr.json
2. Keys present in fr.json but not in en.json (stale translations)
3. Any values in fr.json that appear accidentally untranslated — identical
to the English value, where the English is clearly not shared vocabulary
This is more useful than a plain diff because it distinguishes three types of gaps — missing, stale, and accidentally-untranslated — that each need different actions. Missing keys block a locale from shipping. Stale keys waste translator time. Accidentally-untranslated strings reach users silently.
Step 6: Handling pluralization and interpolation
Pluralization is where i18n gets genuinely complex, and it’s worth getting the structure right before you scale to many keys:
Our app has these plural strings:
- "1 file selected" / "3 files selected"
- "1 unread message" / "2 unread messages"
Using react-i18next and i18next plural suffix conventions (_one, _other),
write the en.json entries and the component code for rendering each string
correctly. Use the i18next recommended ICU plural format.
Always name the i18n library when asking about plural formats. Models have opinions about plural conventions and will pick one — giving it the library name anchors the output to conventions your tooling will actually parse.
Keeping i18n in sync over time
The hardest part of i18n isn’t the initial setup — it’s maintenance. Strings get added during feature development without anyone updating the locale files, and coverage drifts silently.
A lightweight process that scales:
On new string addition: ask the model to add the key to en.json and return a stub entry for each active locale marked __needs_translation: true. The flag is easy to grep in CI.
On string removal: ask the model to identify the key in en.json and all locale files, then remove it everywhere. Stale keys accumulate fast and make coverage audits noisy.
In PR review: include the i18n coverage audit as a standard check for any PR that touches UI components. If a component file changed, compare the keys it uses against en.json. See Evaluating AI-Generated Code Before It Ships for how to integrate this kind of audit into a code review workflow.
The pattern that makes this sustainable is treating en.json as the single source of truth and all other locale files as derived artifacts. When you’re consistent about that hierarchy, the AI can reason about coverage, staleness, and gaps accurately without needing to understand the application logic at all.
A workflow that actually ships
Putting it together as a linear sequence for a new i18n project:
- Run the string audit on each directory, review the output
- Generate
en.jsonfrom the audit with consistent key structure - Replace hardcoded strings component by component, verify each file builds
- Generate locale files from
en.jsonwith__reviewflags on uncertain strings - Human review of flagged strings before shipping each locale
- Add coverage audit to CI so the gap can’t silently accumulate
The AI handles steps 2–4 almost entirely. Steps 1, 5, and 6 require judgment. That’s the right division of labor: AI on the mechanical and consistent work, humans on the calls that affect what real users read.
For codebases with strict type safety requirements, this workflow pairs naturally with Type-Driven AI Development — generating a TypeScript union of valid keys from en.json means the compiler catches missing translation calls before they reach production.

