Language

External Translation Intake API

Three addresses plus a switch that is off by default: the response that reads a group also ships the editing contract (rule version, what must be preserved, how to read the diagnostics), submissions carry the three revision values, and a quality failure returns a fixable breakdown instead of dropping your text.

The external translation intake is three read/write addresses plus one switch, built for the situation where translation is already happening outside the site: human translators, a terminology base, your own translation system. It is not a stand-in for "the model is unavailable" but a formal route into storage — submitted text goes through the same owner-side writer, the same quality checks and the same transactional audit as machine translation, and once stored the shape a visitor reads is identical.

The switch and the permission codes are two separate things. The switch is off by default, and while it is off all three data addresses return 403 with the error code TRANSLATION_EXTERNAL_DISABLED, the message naming the entry point in both console languages. Turning it on requires assistant.translation.external.manage, while reading and writing translations requires assistant.translation.external.write. The split is deliberate: the people allowed to decide whether this chain is open need not be the same accounts allowed to write translations into the site.

Three addresses. GET /api/admin/assistant/translations/external/groups returns the groups currently submittable for one target language; GET …/external?selection_key=… reads that group's source fields and its three revision values, plus the editing contract this data has to obey; POST …/external submits a candidate and stores it.

The contract ships with the data, so you never have to guess the rules. The response that reads one group carries a contract: the current rule version (shaped like misi.markdown-structure/2), a list of what must be preserved item by item (block count and order, emphasis nodes per block, inline code and code blocks verbatim, link and image destinations, list items, table rows, columns and alignment, numeric literals, placeholders, fixed terminology), and the format legend for the diagnostic string itself — which number counts from 1, which value of 0 means "this side has no such marker", and which number is only a count of reported operations rather than of wording errors. This thing is not a second wording copied out of the documentation: the manual-editing screen in the console shows the same one, and the prose written for humans is generated from that same definition (go run ./cmd/translation-contract-doc). Why it is worth building this heavily: a translator or a system standing outside the site, if it cannot get the rules in advance, has exactly one way to "know the rules" — being rejected once. And if the only reason given is "structural marker number whatever is wrong", it has to rewrite the whole judgement itself before it can even talk about fixing it right.

Identity uses that opaque selection_key — do not assemble it yourself from row numbers. For articles the key has the form content:<row id>, and for structured content (navigation items, banners, announcements, theme copy) structured:<content type>:<owner key>:<locale>:<source version>. Both are unique only inside "this one group", carry no meaning when split apart, and treating the integer column in the list as a content id would read you another article's source — a trap most integrators fall into on their first attempt, which is why the interface now hands you that string directly, and the response you read back carries the same value.

A submission must carry all four things. Besides selection_key and fields, it must also have source_version, edit_revision and group_revision. Those three are an optimistic lock: if anyone changed the source text in the meantime, touched this group, or another agent just saved, your submission gets a 409 TRANSLATION_EDIT_CONFLICT rather than writing your translation on top of a source that is no longer correct. fields must contain all fields of that group; missing one returns 400 and names which are missing. For a field whose source really is empty, such as an empty subtitle, submitting an empty string is a legal way to clear it.

Failing the quality gate is not a failure but a fixable rejection. Each candidate is checked field by field for structure, and problems return 422 TRANSLATION_QUALITY_REJECTED with a quality_findings breakdown shaped like body:markdown_structure_mismatch[edits=2;block=5;source_block=5;translated_block=0;source=CodeSpan;translated=none;operation=delete;source_count=1;translated_count=0] — read out, that says "block 5 has one inline code in the source and none on the translation side, so one is missing". This version of the candidate is stored and leaves one audit entry; it simply is not projected to visitors. Clean up the two places named in the breakdown and submit again — you do not have to redo the whole group, and no model call is made. The diagnostics deliberately do not contain the text, URLs, code contents or titles: that material goes into the candidate ledger and into the long-retained audit, whose readership is wider than this chain should have.

The live cross-check on that console screen is not a second gate. Editing a translation by hand shows the same contract and the per-block counts (how many paragraphs, how many emphasis pairs); its job is to say "these do not match" before you press Save, not to compute a second answer to whether storage is allowed — the judgement still lives only on the server side. Equal counts do not mean the order, the destinations and the code are the same either; what decides is the structural diagnostics and the full quality gate at save time.

Nothing needs to be "republished" after storage. An article translation advances the owner's own projection table, so the visitor's next request reads it; site-level configuration (navigation, banners, announcements) still requires the usual single publish click, because their visibility is decided by the snapshot. This matches how manual translation edits in the console behave — there is only one rule.

When you should not use it: when the source text has already changed and that row is marked stale, the interface offers no editing entry and the right action is to rebuild the group against the current source first; when the target language is not enabled on the site, both reads and writes are refused; and if what you expected was "click once and it translates automatically", that belongs to the automatic-submission chain, not to this door.

One detail that integrators most often get wrong: a read failure (the table is mid-migration, storage is temporarily unavailable) and "this group does not exist" are two different answers — the former is 503, the latter 400 or 404. Treating both as "there are no groups to submit" will have your integrator report an empty list while the site is in fact perfectly healthy.