Repository navigation
Machine translations of the README, quickstart and use-case pages stay current through a workflow - #600
Merged
Conversation
zlareb1
force-pushed
the
ci/i18n-translations
branch
2 times, most recently
from
November 13, 2026 06:45
e1966c4 to
4563d08
Compare
…y current through a workflow i18n/<lang>/ holds generated translations into six languages, each stamped with the English page's blob and verified to keep code, links, anchors and numbers. scripts/i18n/translate.py checks and refreshes them, and .github/workflows/i18n.yml opens a pull request after an English edit lands. The hand-written README.zh-CN.md is replaced by i18n/zh-CN/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… orphan and anchor checks, a glossary, pipefail and a main-only job Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…l and banner, link checks in check, concurrent pages and a languages input Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ps every worker, passed pages land, prose-only link checks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ial run; the code-intelligence result states what the three files are Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ints its spend; the localization metric says up to three files, asked for Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
ci/i18n-translations
branch
from
November 13, 2026 06:55
4563d08 to
63a009a
Compare
…; tests for a stopped run's spend and a stale anchor through check Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rites it without translating Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…guage-line cost is documented Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
...
Why
The README had one hand-written translation (
README.zh-CN.md) that drifted whenever the English page changed and needed a hand edit in the same PR. This replaces it with machine translations of a fixed page set (the README, the quickstart and the nine use-case pages) into Simplified Chinese, Japanese, Korean, Brazilian Portuguese, Spanish and Russian, kept current by a workflow instead of by every PR author.scripts/i18n/translate.pysends each page to the Messages API one##section at a time, over the standard library (no new dependency), several pages at once. A section's translation is kept only when its fenced code blocks (in order), inline code spans, link targets, URLs (autolinks and bare ones included), heading anchors and numbers match the English section, and no heading or link text within the set comes back in English (names excepted; a link to an English-only page may keep that page's title). Otherwise the call is retried once with the differences named, then the run fails.href/src, reference definitions; never inside code) are rewritten before translation: a page in the set links to its translation, anything else to the English file on GitHub (images toraw/). Every heading gets an<a id>with its English anchor, computed the waytests/unit/markdown_links.pychecks the English links, so#anchorlinks keep working.source=, the git blob of the English page,model=) and a two-line banner, in the target language and in English, saying the English page is authoritative.translate.py checkreports a page that is missing or whose stamp or banner differs (another English blob, model or banner), a translation of a page no longer inSOURCES, a relative link or#anchorthat points at nothing, a heading or in-set link text left in English, and a README whose language line differs from the generated one. A change to the prompt text changes no stamp:update --all(the workflow'sallinput) translates again.<!-- languages -->markers and is generated, not translated: each README lists all seven languages and links to the other six.checkcompares every README's line with the generated one, andupdaterewrites a line that differs without translating it; a README without the markers stopsupdate. Adding a language changes the English README's line, so its blob, and every README is translated again (a--langrun translates only the languages it names;checkreports the rest until they are)..github/workflows/i18n.ymlruns from main only: on a push that changes the README or anything underdocs/(checkexits clean when nothing is stale), and on a manual run withallandlanguagesinputs. It translates, runscheck --skip-stale(links, anchors, labels and orphans acrossi18n/) before anything is pushed, and opens or updates one PR fromi18n/update, title and body. When some pages fail, the pages that passed still land in that PR and the job then fails (an anchor into or out of a page that is still stale is not checked until that page is translated), so one difficult section does not throw away the rest; once that PR is merged, a later docs push translates only what changed since. Each run starts from main, so while the translations PR is still open a later docs push translates the pages stale on main again (bounded by the cap); merging it promptly keeps runs small. The steps run underbash -o pipefail.python -c "from scripts.i18n import translate as t; print(t.estimate_usd(t.DEFAULT_MODEL, sum(t.request_chars(s, l) for s in t.SOURCES for l in t.LANGUAGES)))"; measured runs cost from about 20% under the estimate to 6% over it) and refuses a run overLOOM_I18N_MAX_USD(5). Every call checks the reported spend against the cap first, so the spend passes it by at most the calls in flight, one per worker. The first page that fails stops every worker before its next call. A timed-out request is not retried (it may have been billed), and an unpriced model is refused.tests/unit/test_i18n.pychecks the generator and the committed files (all 66 present, none orphaned, stamped, bannered, links and anchors resolving, labels translated).Scope and risk
New
i18n/(66 generated files),scripts/i18n/, the workflow, and the README's language line.README.zh-CN.mdandtests/unit/test_readme_translation.pyare removed;i18n/zh-CN/README.mdreplaces them.i18n/is in.prettierignore(generated, never formatted by hand) and in the public-copy scan, andtest_install_script.pyskips it when it collects documented install commands (those blocks are byte copies of the English ones). Four English sentences in three pages change, because translations read "the right file among its three" as a choice among three given candidates and put the 21% cost cut on the wrong run:docs/use-cases/code-intelligence.md, the README's results note and two lines ofdocs/benchmarks/results.md(the summary table and the conceptual-questions protocol) now say the agent is asked to end its answer with up to three files (asbench/agent_localization_ab.pyprompts it), andcode-intelligence.mdstates the cost cut for the runs with Loom.A PR that adds a page to
SOURCEScommits its translations (updatewith anANTHROPIC_API_KEY); the docs rule says so.Model:
claude-sonnet-5-5, effortlow(LOOM_I18N_MODELpicks another priced model). A full run of all 66 pages measured $3.17 (332,930 input and 250,583 output tokens). The committed pages come from that run's prompt revision for four languages and a later one for Chinese and Japanese: 22 pages in 151 s for $1.22, and 20 pages in 162 s for $1.73, six pages at a time; two Japanese pages were then regenerated after a review read a reversed claim in one ($0.31), the README, the quickstart and the code-intelligence page in every language after the rebase onto main ($2.73 against an estimate of $2.57, 218 s), and the README and code-intelligence page again after the English rewording ($0.86; a first attempt stopped when the Japanese README kept a link text in English, which exercised the stop-and-keep-what-passed path). A run after an edit to one page costs a few cents per language.Compatibility, rollout and rollback
ANTHROPIC_API_KEY, and allow GitHub Actions to create pull requests (Settings → Actions → General → Workflow permissions). A PR opened with the workflow token starts no other workflow; close and reopen it to run CI. Until the secret exists the workflow fails when a translation is stale, and the committed translations stay as they are.i18n/and the workflow and restoresREADME.zh-CN.md.Tests
tests/unit/test_i18n.py: 54 tests, passing (the worker-pool test passed three runs in a row).python -m scripts.i18n.translate check: exit 0 on this head.make format-check,make lint,make typecheck: pass.test_i18n.py,test_doc_links.py,test_public_copy.py,test_agent_instructions.py,test_install_script.py: 693 passed on this head (rebased onto main after A burst of package-manager connections no longer kills the sandbox's egress relay #579).tests/uniton 4 workers: 34457 passed;test_deeply_nested_hidden_html_parses_in_bounded_timefails on this host under parallel load and is untouched by this change.okoutput, the PR step, the final failing step). It runs only from main with the secret; the first run after merge shows it.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I checked the verifier against a section whose code span wraps a line (an earlier run stopped on it), the untranslated-label check against every committed page before and after regeneration, the link rewriting from every source directory, and the generated pages listed above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.🤖 Generated with Claude Code