OneKey i18n
Use repository scripts for scanning, merging, previews, upload and verification.
The model selects scope, judges reuse, writes copy and translates.
Rules
- Never manually edit generated locale JSON,
translations.ts or localeJsonMap.ts.
- Runtime translations come from bundled locale JSON (
localeLoaders.ts), not live
Lokalise requests. Remote deletion leaves existing released app bundles unchanged;
subsequent pulls and builds receive the deletion.
- Prefer existing generic keys when meaning, placeholders, capitalization and UI role
match. Do not duplicate legacy keys for naming consistency or change shared copy
unless explicitly in scope.
- Translate every locale listed in the draft; preserve ICU placeholders/tags and
product tone. Do not use English as a placeholder for untranslated languages.
- Use compact summaries, local search and relevant source slices; do not load entire
locale catalogs. Review dynamic expressions and imported copy the scanner cannot resolve.
| Mode |
Missing key or empty/whitespace translation |
Existing non-empty translation |
complete (default) |
Create or fill |
Preserve |
update |
Create or fill |
May update within the requested scope |
Both modes use upsert. Do not silently switch modes to bypass a rejected overwrite.
Workflow
Paths are relative to the repository root; use .tmp/i18n/<task>/ for <dir>.
For <wrapper>, use the configured op (default), keychain or oenv.
If one wrapper is unavailable, check the other installed/configured wrappers
before asking the user to sign in or change credentials; do not configure a new
account on their behalf.
In Codex, oenv requires approved execution outside the sandbox. A sandbox
signature error does not authorize bypassing signature checks or reinstalling the app.
Never print credentials.
Credential loading and remote sync can be silent for tens of seconds. Poll a
running command and allow at least three minutes before diagnosing a timeout;
silence alone is not evidence of missing credentials or an authorization dialog.
An explicit error or user cancellation can stop the wait earlier. Keep the user
informed while waiting, and inspect the process/receipt before retrying a command.
Pull before selecting or translating copy, in both modes:
yarn <wrapper> yarn i18n:workflow sync --project-name "Monorepo v5" --out <dir>/sync.json.
Verify the returned project name/ID. Preserve unknown local generated changes
if the script blocks; use recovery guidance.
Locate the module with rg, then run
yarn i18n:workflow scan --mode <mode> --sync <dir>/sync.json --module <path> --out <dir>/draft.json.
Repeat --module for related copy. For explicit updates to already complete keys,
add --include-complete and limit edits to the requested keys/languages.
Read draft.json.summary.json and relevant code. Search reusable keys with
yarn i18n:search. Choose upsert/reuse or ignore (with a reason); fill missing
or requested translations using the patch format.
Use inspect --file <draft> to check remaining work.
Generate a plan with a new filename:
yarn <wrapper> yarn i18n:workflow preview --file <dir>/draft.json --project-name "Monorepo v5" --out <dir>/plan.json.
Scripts generate JSON, Markdown and HTML; never write one-off preview HTML.
Paste the generated Markdown into the conversation, provide the HTML link,
state mode/change scope, and wait for confirmation. Markdown shows only English
and Simplified Chinese, including old → new wording for updates:
| Key |
Copy |
| key1 |
English text |
|
中文文案 |
If the user returns HTML feedback, follow feedback import.
Edits/comments request a revision, not upload approval. Changes to copy, scope,
mode or remote baseline require a new preview and confirmation.
After confirmation, run
yarn <wrapper> yarn i18n:workflow apply --file <dir>/plan.json --approve <confirmed-hash>.
This uploads, pulls and verifies. Check the receipt and full generated diff,
including unrelated remote changes; use recovery guidance if interrupted.
Wire generated keys into the requested module, rescan and run appropriate checks.
Report project, locale count, upload/pull verification, unrelated generated changes
and code wiring. A prepared preview is not a completed upload.
If keys changed, preserve the old → new mapping. After apply, pull verification
and code migration succeed, prepare the old-key cleanup
list and ask whether to delete it. Translation confirmation does not authorize
deletion; keep old keys unless the user explicitly approves that deletion scope.
Code usage
New keys use semantic_key__title, __action, __desc or __msg.
Legacy mapping: remote global::contact_us → JSON global.contact_us → enum
ETranslations.global_contact_us.
Use useIntl().formatMessage({ id: ETranslations.some_key }) during React rendering,
or appLocale.intl at call time outside React. Do not cache translated text in
module-level constants; keep memo/callback dependencies responsive to locale changes.
For yarn i18n:add compatibility, see single-key commands.
1---2name: 1k-i18n3description: OneKey i18n and Lokalise workflow for module copy, full-language translation create/update, bilingual previews, confirmed upload, pull, and verification. Never edit generated translations.4---56# OneKey i18n78Use repository scripts for scanning, merging, previews, upload and verification.9The model selects scope, judges reuse, writes copy and translates.1011## Rules1213- Never manually edit generated locale JSON, `translations.ts` or `localeJsonMap.ts`.14- Runtime translations come from bundled locale JSON (`localeLoaders.ts`), not live15 Lokalise requests. Remote deletion leaves existing released app bundles unchanged;16 subsequent pulls and builds receive the deletion.17- Prefer existing generic keys when meaning, placeholders, capitalization and UI role18 match. Do not duplicate legacy keys for naming consistency or change shared copy19 unless explicitly in scope.20- Translate every locale listed in the draft; preserve ICU placeholders/tags and21 product tone. Do not use English as a placeholder for untranslated languages.22- Use compact summaries, local search and relevant source slices; do not load entire23 locale catalogs. Review dynamic expressions and imported copy the scanner cannot resolve.2425| Mode | Missing key or empty/whitespace translation | Existing non-empty translation |26| -------------------- | ------------------------------------------- | ------------------------------------- |27| `complete` (default) | Create or fill | Preserve |28| `update` | Create or fill | May update within the requested scope |2930Both modes use `upsert`. Do not silently switch modes to bypass a rejected overwrite.3132## Workflow3334Paths are relative to the repository root; use `.tmp/i18n/<task>/` for `<dir>`.35For `<wrapper>`, use the configured `op` (default), `keychain` or `oenv`.36If one wrapper is unavailable, check the other installed/configured wrappers37before asking the user to sign in or change credentials; do not configure a new38account on their behalf.39**In Codex, oenv requires approved execution outside the sandbox.** A sandbox40signature error does not authorize bypassing signature checks or reinstalling the app.41Never print credentials.42Credential loading and remote sync can be silent for tens of seconds. Poll a43running command and allow at least three minutes before diagnosing a timeout;44silence alone is not evidence of missing credentials or an authorization dialog.45An explicit error or user cancellation can stop the wait earlier. Keep the user46informed while waiting, and inspect the process/receipt before retrying a command.47481. **Pull before selecting or translating copy**, in both modes:49 `yarn <wrapper> yarn i18n:workflow sync --project-name "Monorepo v5" --out <dir>/sync.json`.50 Verify the returned project name/ID. Preserve unknown local generated changes51 if the script blocks; use [recovery guidance](references/rules/i18n.md#recovery).522. Locate the module with `rg`, then run53 `yarn i18n:workflow scan --mode <mode> --sync <dir>/sync.json --module <path> --out <dir>/draft.json`.54 Repeat `--module` for related copy. For explicit updates to already complete keys,55 add `--include-complete` and limit edits to the requested keys/languages.563. Read `draft.json.summary.json` and relevant code. Search reusable keys with57 `yarn i18n:search`. Choose `upsert`/reuse or `ignore` (with a reason); fill missing58 or requested translations using [the patch format](references/rules/i18n.md#fill-a-draft).59 Use `inspect --file <draft>` to check remaining work.604. Generate a plan with a new filename:61 `yarn <wrapper> yarn i18n:workflow preview --file <dir>/draft.json --project-name "Monorepo v5" --out <dir>/plan.json`.62 Scripts generate JSON, Markdown and HTML; never write one-off preview HTML.635. **Paste the generated Markdown into the conversation**, provide the HTML link,64 state mode/change scope, and wait for confirmation. Markdown shows only English65 and Simplified Chinese, including old → new wording for updates:6667 | Key | Copy |68 | ---- | ------------ |69 | key1 | English text |70 | | 中文文案 |7172 If the user returns HTML feedback, follow [feedback import](references/interactive-review.md).73 Edits/comments request a revision, not upload approval. Changes to copy, scope,74 mode or remote baseline require a new preview and confirmation.75766. After confirmation, run77 `yarn <wrapper> yarn i18n:workflow apply --file <dir>/plan.json --approve <confirmed-hash>`.78 This uploads, pulls and verifies. Check the receipt and full generated diff,79 including unrelated remote changes; use recovery guidance if interrupted.807. Wire generated keys into the requested module, rescan and run appropriate checks.81 Report project, locale count, upload/pull verification, unrelated generated changes82 and code wiring. A prepared preview is not a completed upload.838. If keys changed, preserve the old → new mapping. After apply, pull verification84 and code migration succeed, prepare the [old-key cleanup](references/rules/i18n.md#old-key-cleanup)85 list and ask whether to delete it. Translation confirmation does not authorize86 deletion; keep old keys unless the user explicitly approves that deletion scope.8788## Code usage8990New keys use `semantic_key__title`, `__action`, `__desc` or `__msg`.91Legacy mapping: remote `global::contact_us` → JSON `global.contact_us` → enum92`ETranslations.global_contact_us`.9394Use `useIntl().formatMessage({ id: ETranslations.some_key })` during React rendering,95or `appLocale.intl` at call time outside React. Do not cache translated text in96module-level constants; keep memo/callback dependencies responsive to locale changes.9798For `yarn i18n:add` compatibility, see [single-key commands](references/rules/i18n.md#single-key-commands).