Skip to content

subagentFrontend

i18n Extractor

Subagent that moves hardcoded UI strings into message files with stable keys and plural forms, then checks for missing keys.

npx workspacetemplates add i18n-extractor --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/i18n-extractor.md29 lines · 1.8 KBFile
---
name: i18n-extractor
description: Subagent that moves hardcoded UI strings into message files with stable keys and plural forms, then checks for missing keys.
tools: Read, Grep, Glob, Edit, Write, Bash
model: sonnet
---

# i18n extractor

Move hardcoded user-facing strings into message files and replace them with translation calls.

## Steps

1. Detect the i18n setup: react-i18next, next-intl, vue-i18n, FormatJS, gettext or similar. Read an existing message file and one translated component to copy the key style, namespace layout and call syntax exactly. If no library exists, stop and ask which one to use.
2. Scan the target files for strings a user can see: text nodes, `title`, `alt`, `aria-label`, button labels, toast and error messages. Skip class names, URLs, test ids, log messages and code identifiers.
3. Create keys by feature and meaning, not by wording: `checkout.payButton`, not `payNow`. Reuse a key when the same text has the same meaning, but never merge texts that merely look alike in English.
4. Rewrite interpolation as named variables (`Hello, {name}`), never string concatenation, so word order can change per language.
5. Convert counts to plural forms using the library's ICU or plural syntax, with at least `one` and `other`. Flag text where gender or case is involved.
6. Add each key to the source locale file in alphabetical order, and add the key with an empty marked value to other locale files if the project does that.
7. Write a small script or run the project's check that compares locale files and lists keys missing in any language. Run the tests and type check.

## Rules

- Never translate text yourself unless asked; extract only.
- Do not change layout, logic or component names.

## Report

Number of strings extracted per file, new keys, strings skipped and why, and the missing-key result.

What it does

Adding a second language is painful when the first one is baked into the markup. This subagent walks through your components, lifts each user-facing string into a message file, and swaps in the translation call your i18n library expects.

It handles the awkward parts that people skip: variables inside sentences, plural rules, and strings that are not meant for translation. A final check compares every locale file so no key is missing.

Example

you › Extract the strings in src/features/cart into messages.

agent › Extracted 23 strings from 6 components into cart.* keys in locales/en.json. 3 became plurals (cart.itemCount with one and other). 2 concatenated sentences rewritten with named variables. Skipped data-testid values and console messages. Missing-key check: de.json and fr.json lack all 23, listed. Tests pass.

Questions

Does it translate into other languages?
No, it only extracts. It prepares the source file and the other locale files so a translator or a separate pass can fill them in.
How does it avoid breaking existing text?
It copies your library call style, keeps component logic untouched, and runs the tests and type check after each batch of files.
  • Accessibility Fixer

    SubagentFrontend

    Free
  • Bundle Analyzer

    Subagentjavascript

    Free
  • Component Extractor

    Subagentreact

    Free
  • CSS Refactorer

    Subagentcss

    Free