Skip to content

Translate OpenCode Mobile into 56 languages on iOS and Android - #1138

Merged
ivanfenenko merged 12 commits into
mainfrom
feature/1130-translate-56-languages
Nov 29, 2026
Merged

ivanfenenko merged 12 commits into
mainfrom
feature/1130-translate-56-languages

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Translates OpenCode Mobile into the 56 left-to-right languages the OpenCode desktop app and the official OpenCode Android app ship, on both iOS and Android, and adds the tooling that keeps them complete.

Fixes #1130.

What changes

  • 56 languages on both apps. android/app/src/main/res/values-<code>/strings.xml, the iOS Localizable.xcstrings, and a new InfoPlist.xcstrings for the iOS permission prompts. 1,525 strings per language. Right-to-left languages stay out until a right-to-left layout pass.
  • translate skill and scripts/translate.mjs: translation happens in the session that changes the copy. The script calls no model; status lists what is missing or stale, tasks writes small task files (each string once with its notes, then each language's form of address and term words), and apply checks the answers and writes both apps, translating each key once for both when their English matches. The agent pulls context with scripts/l10n/lookup.mjs only where a string needs it and checks each answer with scripts/l10n/check-answer.mjs. One new string in all 56 languages is about 9k characters of tasks. The OpenCode desktop app's terms (l10n/desktop-terms.json, MIT) and each language's chosen words (l10n/terms.json) keep terms consistent.
  • l10n/source-hashes.json records the English each key was translated from, so a key whose English changes is translated again.
  • scripts/check-translations.mjs (String Checks) fails on missing or stale translations, mismatched placeholders, plural forms each language needs (CLDR), escaping, lost brand names, and language lists that drift from scripts/l10n/languages.mjs. Tests in scripts/l10n/l10n.test.mjs.
  • Platform wiring. Android appLanguages feeds localeFilters (library translations only for our languages) with lint MissingTranslation / ExtraTranslation / MissingQuantity as errors; iOS knownRegions lists the languages.
  • Docs. docs/translating.md and a Translations section in AGENTS.md.

Quality

Every language went through, in order:

  1. Translation (Claude Sonnet).
  2. A full review of every string with its context (Claude Opus for de, fi, ja, ru, uk; Sonnet for the rest): grammar with each placeholder filled in, every plural form, wrong senses and calques (for example "shell" rendered as a word for eggshell in about 20 languages), and terms.
  3. A consistency pass that picks one word per product term and one form of address per language, then a sweep that applies the chosen term to every string that uses it. Korean now uses 해요체 throughout.

l10n/review-status.json records the review and consistency pass for each language. No native speaker has reviewed these yet.

Checks

  • node scripts/check-translations.mjs: Translations OK, 56 languages × 1525 strings on Android and iOS.
  • node scripts/check-string-keys.mjs, node scripts/check-hardcoded-text.mjs --strict, node --test scripts/l10n/*.test.mjs: pass.
  • Android :app:assembleDebug builds.
  • The iOS keyboard hint (OpenCodeKeyboardHint) now wraps instead of truncating, as it already did on Android.
  • iOS simulator build passes.
  • Screenshots of Home, Session Chat and Settings in de, fi, ja, th, my and ka on both platforms are in the comment below, against the scenario harness. No clipped text; the one truncation found (the iOS keyboard hint in German) is fixed in this PR.

Risks / Follow-ups

Adds scripts/translate.mjs, which translates each key once for both apps
and writes android/app/src/main/res/values-<code>/strings.xml and the iOS
Localizable.xcstrings and InfoPlist.xcstrings. A lockfile records the
English each key was translated from, so changed English is translated
again.

Adds scripts/check-translations.mjs to String Checks. It fails on missing
or stale translations, mismatched placeholders, plural forms, escaping and
language lists that drift from scripts/l10n/languages.mjs.

The languages match the OpenCode desktop app's left-to-right set. The
Android locale config, localeFilters and lint, and the iOS knownRegions,
list them. docs/translating.md explains the workflow.
Adds a review pass that fixes grammar with placeholders filled in,
plural forms, unnatural wording, terms and register, and records each
reviewed language in l10n/review-status.json. Adds a hand-off mode so
other agents can answer translation and review requests, and a script
that writes per-language term-consistency requests.
Fixes grammar with placeholders filled in, plural forms, literal
calques (shell, redacted, scheme), wrong word senses and terms that
differed between screens. l10n/review-status.json records each language.
Every language has a model review. A term-consistency pass picks one
word per product term and one form of address per language, and a
sweep applies the chosen term to every string that uses it.
Applies a consistency pass and a term sweep to all 56 languages, and
moves Korean to one politeness level (해요체).
Longer translations (German) cut off the Press Tab hint under a question
card. Android already wraps it.
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Screenshots: de, fi, ja, th, my, ka

Debug builds of this branch against the scenario harness (v2, scripted fake model), per-app language set on each device. Home, Session Chat (a question card) and Settings in each language. Checked for clipped or truncated text: none left. The one problem found, the iOS "Press Tab" keyboard hint truncating in German, is fixed in 74e594c (it now wraps, as on Android).

Language Screen iOS Android
de home ios de home android de home
de session ios de session android de session
de settings ios de settings android de settings
fi home ios fi home android fi home
fi session ios fi session android fi session
fi settings ios fi settings android fi settings
ja home ios ja home android ja home
ja session ios ja session android ja session
ja settings ios ja settings android ja settings
th home ios th home android th home
th session ios th session android th session
th settings ios th settings android th settings
my home ios my home android my home
my session ios my session android my session
my settings ios my settings android my settings
ka home ios ka home android ka home
ka session ios ka session android ka session
ka settings ios ka settings android ka settings

@ivanfenenko
ivanfenenko marked this pull request as ready for review November 28, 2026 14:18

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 1 finding(s) that 2+ of 3 passes agreed on.

6 finding(s) from a single pass, not posted
  • android/app/build.gradle.kts:150 high: localeFilters reuses resource qualifiers instead of BCP47 tags (muse-spark-1.3-contributor)
  • scripts/translate.mjs:740 high: String answer for a plural is silently expanded to every form (muse-spark-1.3-contributor)
  • scripts/l10n/rules.mjs:102 medium: Non-other plural may drop any placeholder, not just the count (muse-spark-1.3-contributor)
  • scripts/check-translations.mjs:158 medium: Android escaping check misses closing markup (muse-spark-1.3-contributor)
  • scripts/translate.mjs:602 medium: Translate skips plurals that are present but missing required CLDR forms (deepseek-v4.1-flash)
  • scripts/check-translations.mjs:171 low: knownRegions parser drops the last entry when it has no trailing comma (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.158

Comment thread scripts/translate.mjs Outdated
const complete = languages.length === LANGUAGES.length;
for (const unit of units) {
const missing = [...failures.keys()].some((f) => f.split(" ")[1].split("#")[0] === unit.key);
if (complete && !missing) lock[unit.key] = unit.hash;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium: Lockfile marks unprocessed keys as current when a filtered run covers all languages

After a run, every unit with no entry in the failures map gets lock[unit.key] = unit.hash, but failures only contains strings that were actually attempted. The --keys filter (line 597, if (args.keys && !args.keys.has(unit.key)) continue;) and the --limit truncation (line 613) remove units from the work list before they can ever fail, so they are locked as "translated from this English" without being checked. Once locked, check-translations.mjs's stale-English gate (lock[u.key] !== u.hash) passes for those keys forever, and future translate.mjs all runs skip them (translations exist and the key is not stale), so the source-hashes mechanism this PR introduces silently stops working for those keys.

Failure scenario: English of an existing translated key (e.g. home.project_count) is reworded; a developer then runs node scripts/translate.mjs all --keys new_key (or with --limit) to fill a different gap -> the changed key is marked current in l10n/source-hashes.json without retranslation -> the stale-English check in CI passes and every language keeps the translation of the old English indefinitely.

Found by 2 of 3 passes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cc1c2f4. translate.mjs no longer has this run loop: tasks records in plan.json the keys its tasks cover and which of them were stale, and apply updates l10n/source-hashes.json only for those keys. A stale key is recorded only when its tasks covered every language and none failed, so a filtered run (--keys, or some languages only) leaves other stale keys stale and CI keeps failing them. Checked by making two keys stale and running tasks for one: only that key was recorded.

A changed string used to cost a request per language (56), each repeating
the string's context, and --review re-read every string in every
language. Now a few changed strings go out for many languages in one
request, with one code line of context instead of two, the words each
language chose (new l10n/terms.json) instead of sample translations, and
--review checks only what the run translated (--review-all for every
string). --dry-run reports how much a run would send.
Hand-off tasks now hold only each string, its notes and each language's
form of address and term words. Agents look up more with
scripts/l10n/lookup.mjs (code usage, same-screen strings and their
translations, how a phrase is already translated) only where a string
needs it, and run scripts/l10n/check-answer.mjs until their answer has
no errors; the term check flags a missing chosen word as a hint.

Fixes string notes: a comment was carried past blank lines onto every
later string, so most strings got another string's note. A sentence
comment now describes the next string only, and a heading covers only
keys that share its first strings' prefix.
- lookup.mjs takes several ids and languages in one call, labels current
  translations (and ones made from older English), names the function
  or view around each usage, and skips nearby strings for common.*.
- Bare short strings with no note carry one code line in the task, so an
  agent that never looks anything up still sees how they're used. Notes
  that repeat the English are dropped.
- check-answer.mjs rejects language codes the task doesn't have and plural
  strings answered with one text, and hints at stray spaces, a dropped
  … or ·, the desktop word missing where no word was chosen, and a
  translation that differs from the same English elsewhere in the app.
- A task covers at most 10 languages, same script and plural forms
  together. Glossary terms match whole words.
@ivanfenenko

ivanfenenko commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Adding new copy in a feature

Updated: translation now happens in the session working on the feature, through the translate skill (.agents/skills/translate/SKILL.md). The script calls no model and starts no server. Details: docs/translating.md.

1. Add the English on both platforms

  • Android: android/app/src/main/res/values/strings.xml
  • iOS: ios/OpenCode Mobile/OpenCode Mobile/Localizable.xcstrings

Use matching keys (area.name on iOS, area_name on Android). When the key doesn't make the text's role obvious, write one sentence above the Android string or in the catalog comment saying what it is and what each placeholder holds, for example <!-- Button on the archive dialog. %1$s is the session title. -->. The translator reads these notes.

2. Translate with the skill

Hand the translation step to one fresh subagent (Sonnet is enough): "Load the translate skill and translate the app's missing strings." A long feature session would re-send its whole context on every turn; translating needs only the strings and their notes. The subagent:

node scripts/translate.mjs tasks                      # writes small tasks and prints them when small
# writes every answer in one turn, looking up context only where a string is unclear (scripts/l10n/lookup.mjs)
node scripts/l10n/check-answer.mjs <task folder>      # 0 errors; hints weighed
node scripts/translate.mjs apply <task folder>        # checks again, writes both apps, runs check-translations

About four turns for a small change. One new string in all 56 languages is 6 tasks, about 10k characters. Many tasks (a big feature, a new language) fan out to one subagent per task.

3. Commit with the feature

values-*/strings.xml, Localizable.xcstrings, InfoPlist.xcstrings (permission prompts) and l10n/source-hashes.json. The String Checks workflow fails a pull request with a missing translation, one made from older English, or a broken placeholder.

Changing existing text

  • Meaning changed: the key is stale, and tasks includes it in every language. A change of meaning with little change to the text: tasks --redo <key>.
  • Typo fix with the same meaning: node scripts/translate.mjs accept <key> keeps the translations.
  • A bad translation: edit values-<code>/strings.xml and the catalog entry by hand, or tasks --review --keys <key>.

Without an agent, push the English only and say so in the pull request; a maintainer translates before merge. Hex Code isn't translated yet.

…server

scripts/translate.mjs no longer calls a model, starts an opencode server
or runs sessions. It has four commands: status (what is missing or
stale), tasks (write small task files), apply (check the answers and
write both apps) and accept (keep translations after a typo fix).

The agent working on a change follows the new translate skill: it works
the tasks itself, or gives one task each to subagents when there are
many, pulls context with lookup.mjs where a string needs it, and checks
each answer with check-answer.mjs before apply. The translation and
review rules live in the skill, so task files hold only data: one new
string in all 56 languages is about 9k characters of tasks.
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor

cursor Bot commented Nov 28, 2026

Copy link
Copy Markdown

This PR is too large for Bugbot to review. It changes 47,947 lines and 3,536,075 characters. Split the change into smaller pull requests to get a review.

… turns

From a review of the skill flow:
- apply records only the keys its tasks covered. A stale key not in the
  tasks, or translated again in only some languages, stays stale; the
  same holds for iOS permission prompts, which --redo can now name.
- A key with no source-hash entry is new, not stale, for status and
  tasks; status lists keys translated everywhere but unrecorded, which
  CI fails, and points to accept.
- check-answer takes the whole task folder, rejects an answer without
  its translations or fixes object, and names the other string in the
  same-English hint. apply runs it first and check-translations last.
- tasks prints small tasks in full, so a small change is four turns:
  tasks, answers, check, apply. The skill runs the step in one fresh
  subagent and fans out only for many tasks.
- check-translations points to the skill instead of removed commands.
  Review status is no longer written; nothing read it.
From the automated review on #1138:
- status and tasks treat a translation that fails the checks (a plural
  missing a form the language needs) like a missing one, so tasks
  copies or translates it again instead of reporting nothing to do.
- The Android escaping check also rejects a closing tag inside a string.
- The knownRegions parser keeps a last entry with no trailing comma.
@ivanfenenko

ivanfenenko commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Responses to the automated review, including the single-pass findings in its summary:

Finding Outcome
Lockfile marks unprocessed keys current (translate.mjs:671) Fixed in cc1c2f4, see the reply on the thread.
String answer for a plural expanded to every form (translate.mjs:740) Fixed in cc1c2f4: a plain string for a plural is now an error in check-answer.mjs and apply.
Plurals present but missing required CLDR forms are skipped (translate.mjs:602) Fixed in 726b60d: a translation that fails the checks counts as missing, so tasks copies it from the other platform or translates it again, and status reports it.
Android escaping check misses closing markup (check-translations.mjs:158) Fixed in 726b60d.
knownRegions parser drops a last entry with no trailing comma (check-translations.mjs:171) Fixed in 726b60d.
localeFilters uses resource qualifiers instead of BCP 47 (build.gradle.kts:150) Not a bug: the AGP localeFilters docs accept either form, en-rUS or b+sr+Latn+RS.
Non-other plural forms may drop any placeholder, not just the count (rules.mjs:102) Left as is. The neutral form doesn't record which placeholder holds the count, so the rule allows any one to be dropped and fails when two or more are. Of the app's 102 plurals, 97 have only the count and 5 have one more placeholder; for those 5, a form other than other that drops the second placeholder instead of the count would pass. A known gap, left until plurals record which argument is the count.

Cursor Bugbot skipped the PR as too large (most of the diff is the 56 generated string files). The tooling is in scripts/translate.mjs, scripts/l10n/, scripts/check-translations.mjs and .agents/skills/translate/ if a narrower review is useful.

@ivanfenenko
ivanfenenko added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit 439a697 Nov 29, 2026
18 checks passed
@ivanfenenko
ivanfenenko deleted the feature/1130-translate-56-languages branch November 29, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Localisation: translation service and first language

1 participant