Skip to content

/wbTranslate — Exhaustive Simulation () ​

/wbTranslate is the i18n bootstrap. Its job is to lift hardcoded user-facing strings into a translation file, leaving placeholders in the original code, and producing a localization-ready scaffold. It does not invent translations; it does not produce localized variants; it sets up the infrastructure for translation work.

Read this if you want to know what counts as a "user-facing string," why /wbTranslate has only one flag, and where translation bootstrap ends and translation content begins.


1. Role & target ​

AspectBehavior
RoleThe Translator — i18n scaffolding, not localized content.
TargetA file or directory containing user-facing strings.
Cell scopeNone.
Side effects allowedEditing source code (replace hardcoded strings with t('key') calls); creating/updating i18n/<locale>.json or equivalent; producing a glossary file for the translation team.
Side effects forbiddenInventing translations; producing localized variants without explicit --new-only opt-in; modifying tests; touching code that isn't user-facing.

The "no invented translations" rule is the contract. The tooling job is mechanical: find strings, key them, replace with calls. The content job (translating "Submit" to "Soumettre") is human work, or a different model run with the right context. Mixing the two produces fake-looking localizations that nobody trusts.


2. Argument resolution matrix ​

FormExampleWhat /wbTranslate does
FileCommand: /wbTranslate src/components/LoginForm.vueScans for user-facing strings; lifts them into the locale file; replaces with t() calls.
DirectoryCommand: /wbTranslate src/components/Walks the directory; one locale file aggregating all keys.
Free-textCommand: /wbTranslate "the login flow"Refused. Translation is path-required (string-extraction needs file scope).

What counts as a "user-facing string" ​

A heuristic, applied per file type:

ContextString is user-facing if...
Vue/React component templateIt appears as text content of a DOM element, or as a placeholder / aria-label / title attribute.
Vue/React script sectionIt's passed to a known UI emitter (toast, alert, error throw with user-visible message).
Form labels, button textAlways user-facing.
Console.log / debugNever user-facing — left alone.
Error messages thrown to internal callersNot user-facing — left alone.
URLs, regex patterns, technical constantsNever user-facing — left alone.

The heuristic is conservative: when uncertain, leave the string alone and surface it as a "candidate?" question rather than auto-extracting.


3. Flag matrix ​

/wbTranslate has one flag.

FlagShortcutPurpose
--new-only-nOnly extract strings that aren't already in the locale file. Skip already-keyed content.

Without --new-only, every user-facing string in the target gets re-keyed (with collision handling — same string maps to same key). With --new-only, the agent assumes existing keys are correct and only adds new ones.

The -n flag is for the maintenance case: someone added 3 new strings to a component that's already partially translated. You don't want to re-key the existing 20; you want only the 3 new ones.


4. Pipelines (the agent-native scenarios) ​

📋/wbTranslate Exhaustive Simulation
First-time bootstrap of a component/wbTranslate core2/packages/wb-core/src/components/LoginForm.vue
> /wbTranslate core2/packages/wb-core/src/components/LoginForm.vue
[SYSTEM] Target: LoginForm.vue
[SCAN] Reading file (94 lines)...
[CANDIDATES IDENTIFIED]
Template (8 user-facing strings):
- Line 4: "Sign in to your account"
- Line 7: "Email address" (label)
- Line 8: "Enter your email" (placeholder)
- Line 12: "Password" (label)
- Line 13: "Enter your password" (placeholder)
- Line 17: "Sign in" (button text)
- Line 21: "Forgot password?" (link text)
- Line 25: "Don't have an account? Sign up" (link text)
Script (2 user-facing strings):
- Line 41: throw new Error("Invalid credentials") — visible
to user via toast.
- Line 47: emit('toast', "Welcome back") — toast text.
[NOT EXTRACTED] (heuristic: not user-facing)
- Line 23: 'tabindex="0"' — DOM attribute value.
- Line 33: console.log('LoginForm mounted') — debug.
[GENERATING KEYS]
loginForm.heading: "Sign in to your account"
loginForm.email.label: "Email address"
loginForm.email.placeholder: "Enter your email"
loginForm.password.label: "Password"
loginForm.password.placeholder: "Enter your password"
loginForm.submit: "Sign in"
loginForm.forgotPassword: "Forgot password?"
loginForm.signUp: "Don't have an account? Sign up"
loginForm.errors.invalidCredentials: "Invalid credentials"
loginForm.toast.welcome: "Welcome back"
[CONFIRM] Proceed with extraction (10 strings → 10 keys; LoginForm.vue
updated; i18n/en.json populated)? [y/N] > y
[EDIT] LoginForm.vue: replaced literals with t('loginForm.<key>') calls.
[EDIT] i18n/en.json: added 10 keys.
[NEW FILE] i18n/glossary.md: scaffolded with the 10 new entries +
context notes for translators (e.g., "loginForm.submit
appears as a button on the login page; verb form").
[OK] Bootstrap complete. en.json is the only locale; create fr.json,
ar.json, etc. by copying en.json and translating values.
[NOTE] /wbTranslate did NOT translate any strings. en.json contains
the original English. Other locales are empty until human
translators or a later pass fill them in.

💠 Pipeline First-time bootstrap of a component ​

💠 Pipeline Maintenance pass with --new-only ​

After Pipeline A, the developer adds 2 new strings to LoginForm.vue. Running again:

💠 Pipeline Refusal on ambiguous case ​

A user runs /wbTranslate on a file mostly full of error strings:


5. Edge cases & refusals ​

TriggerWhat /wbTranslate does
No targetHalt.
Free-text targetHalt — file/directory required.
Target has no user-facing stringsOne-line "nothing to translate." Exit 0.
Target with mixed locales alreadyRefuse — running /wbTranslate on a partially-translated file is risky without -n. Suggests re-running with --new-only.
String contains placeholders / interpolationsLift the template, not the interpolated values: t('key', { name: user.name }).
Same string appears multiple timesGenerate one key, reuse across call sites.
--new-only and the existing locale file is corruptedHalt — needs human inspection of the locale file before maintenance can proceed.
Test files in targetSkip — test strings aren't user-facing.
User asks for translation contentRefuse politely. /wbTranslate produces scaffolding; content is human or a separate model run.

The pattern: /wbTranslate is i18n bootstrap, not i18n content. It identifies user-facing strings via a conservative heuristic, replaces them with key calls, populates the source-locale file, generates a translator-facing glossary. It refuses to invent translations, refuses to act on ambiguous targets, refuses scope shapes that don't produce reliable extraction. The output is a foundation that humans (or follow-on translation processes) can build on.