Repository navigation
Translate OpenCode Mobile into 56 languages on iOS and Android - #1138
Conversation
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.
Screenshots: de, fi, ja, th, my, kaDebug 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). |
There was a problem hiding this comment.
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:150high: localeFilters reuses resource qualifiers instead of BCP47 tags (muse-spark-1.3-contributor)scripts/translate.mjs:740high: String answer for a plural is silently expanded to every form (muse-spark-1.3-contributor)scripts/l10n/rules.mjs:102medium: Non-other plural may drop any placeholder, not just the count (muse-spark-1.3-contributor)scripts/check-translations.mjs:158medium: Android escaping check misses closing markup (muse-spark-1.3-contributor)scripts/translate.mjs:602medium: Translate skips plurals that are present but missing required CLDR forms (deepseek-v4.1-flash)scripts/check-translations.mjs:171low: 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
| 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Adding new copy in a featureUpdated: translation now happens in the session working on the feature, through the 1. Add the English on both platforms
Use matching keys ( 2. Translate with the skillHand 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-translationsAbout 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
Changing existing text
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.
|
@cursor review |
|
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.
|
Responses to the automated review, including the single-pass findings in its summary:
Cursor Bugbot skipped the PR as too large (most of the diff is the 56 generated string files). The tooling is in |




































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
android/app/src/main/res/values-<code>/strings.xml, the iOSLocalizable.xcstrings, and a newInfoPlist.xcstringsfor the iOS permission prompts. 1,525 strings per language. Right-to-left languages stay out until a right-to-left layout pass.translateskill andscripts/translate.mjs: translation happens in the session that changes the copy. The script calls no model;statuslists what is missing or stale,taskswrites small task files (each string once with its notes, then each language's form of address and term words), andapplychecks the answers and writes both apps, translating each key once for both when their English matches. The agent pulls context withscripts/l10n/lookup.mjsonly where a string needs it and checks each answer withscripts/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.jsonrecords 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 fromscripts/l10n/languages.mjs. Tests inscripts/l10n/l10n.test.mjs.appLanguagesfeedslocaleFilters(library translations only for our languages) with lintMissingTranslation/ExtraTranslation/MissingQuantityas errors; iOSknownRegionslists the languages.docs/translating.mdand a Translations section inAGENTS.md.Quality
Every language went through, in order:
l10n/review-status.jsonrecords 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.:app:assembleDebugbuilds.OpenCodeKeyboardHint) now wraps instead of truncating, as it already did on Android.Risks / Follow-ups