tool_lang
Side-by-side multilingual editing of a single text component, with one-click automatic translation of its data from a source language to a target language using a configured translation engine.
What it does / why & when to use it
tool_lang opens a two-pane editor on one text component of one record: the left pane shows the component's value in a source language (read-only), the right pane the same component in a target language (editable). The cataloguer picks both languages from the language selects, then either:
- presses Automatic translation to fill the target from the source through a translation engine, or
- presses Copy to target to copy the source value verbatim (useful as a starting point for hand-translation, or for non-translatable strings).
The point is that Dédalo stores every textual value per language (lg-eng, lg-spa, …) on the same component. tool_lang makes maintaining those parallel values a focused, comparison-driven task instead of switching the whole record's interface language back and forth.
Concrete heritage scenario: a museum publishes its Objects catalogue trilingually. A curator has written the long Description (a component_text_area) in Spanish but the English and Catalan versions are empty. They open tool_lang on that Description, set Source language = Spanish, Target language = English, choose the Babel engine and press Automatic translation; the English value is produced by the external machine-translation service and saved on the component. The curator then switches the target select to Catalan, repeats, and lightly edits each machine draft in place. For a single record, this is the day-to-day translation workflow; to translate a component into many languages at once, see tool_lang_multi.
Use it when: a record's text component needs a translated (or copied) value in another language, edited with the source visible alongside. Do not use it for bulk translation across many records (no such action exists here) or for non-text components.
How it works (server + client)
The tool is element-driven and component-scoped: it is wired onto a specific text component through that component's ontology properties->tool_config->tool_lang, whose ddo_map declares the roles the client reads. The heavy lifting is split between a server engine (online services) and a client engine (in-browser AI).
Client (tools/tool_lang/js/):
tool_lang.jsis the instance.init()loads the project default languages (addinglg-nolanwhen the caller component is no-lang) and restores the last-used engine from local DB (translator_engine_selectin thestatustable).build()resolves theddo_maproles into live component instances —main_element(the source component),target_component(a second instance of the same component bound to the target lang, created viaload_componentwithid_variant:'target_component'), and optionalstatus_user_component/status_admin_component— and restores the last target lang (tool_lang_target_lang).render_tool_lang.jsbuilds the two-pane edit UI: source select + read-only source component on the left, target select + editable target component on the right, plus the Automatic translation block (engine<select>, run button, gear-toggled configuration with a CPU/wasmdevice checkbox) and the Copy to target button. Copy writessource.data.valueonto the target component and saves it per item.- Pressing Automatic translation dispatches on the selected engine's
type. Aserverengine (e.g. Babel, Google) callstool_lang.prototype.automatic_translation_server(), which sends theautomatic_translationrequest throughdd_tools_api(long timeout, retries) and refreshes the target component on response. Abrowserengine (browser_transformer, "Local AI translator") callsautomatic_translation_browser()→ the sharedbrowser_translation.jsengine, which runs the chosen model entirely in a reused Web Worker (translators/browser_transformer/browser_transformer.js: HuggingFace Transformers + ONNX, WebGPU orwasm) with a streaming overlay — no server round-trip and no API action. The runtime is the registry-served transformers.js bundle (/dedalo/lib/transformers/, a digest-pinned vendored tree since 2026-09-04), its WASM glue the localonnxruntimepin, and the model files come from the install's model store (/dedalo/ai_models/,src/core/ai/model_store.ts— session-gated, digest-checked, operator-seeded), the same doortool_transcriptionuses; nothing model-shaped lives in the tools tree (gated:dependency_integrity_tripwiremodel-artifact leg,no_remote_code_tripwireleg 3). - The model catalogue. The browser engine's entry in
translator_enginecarries amodelsarray; the configuration panel offers a Model selector (labelengine_<name>) and a Quality selector, shown only for a model pinned at more than one quantisation (adtypeslist in its entry; none is yet, so it stays hidden).tools/tool_lang/js/browser_models.jsholds the same list as the fallback for a stored tool config that predatesmodels(gate:tool_lang_placeholder_repair— it must equal bothregister.jsoncopies). The selector keeps only the models the installation offers, and the worker runs the definition it is sent: there is no fallback model and no lookup by name, so a run with no offered model is refused before the worker starts (no_model). Every model is pinned by hub revision and per-file sha256 insrc/core/ai/model_pins.json, with the licence that governs it;bun run scripts/fetch_ai_models.ts --listshows them,scripts/pin_ai_models.tsis the one way to change a pin. See The browser model catalogue below. - Marks and markup in the browser engine. The model never sees a Dédalo mark (index in/out, tc, svg, draw — the pre-4.9.0 name of svg, still in records —, geo, page, person, note, reference, lang — the
tr.jspatterns; every key oftr.jsget_mark_patternis one of these, an alias of one, or a stated non-mark, a gate in the identity test) nor any HTML it could corrupt.browser_translation.jsreplaces each mark with a numbered token[[[n]]]in document order (placeholders.js), then converts the value to Markdown (markdown_utils.js): paragraphs, line breaks, bold, italic, underline and inline code become Markdown, and every other element (<span style>,<sup>,<a href>,<img>, headings, lists, quotes, rules, tables,<div>, anything unknown) is shielded behind tokens too. A shielded tag is restored as the browser serialises it from the source (DOMParser+outerHTML: attribute quoting and entities normalised, the form an editor saves), not as a byte copy of the stored string.<pre>is one token and is not translated; so is every HTML comment, and every element with nothing to translate (a<p> </p>spacer, an empty cell), restored as written. A<p>,<strong>,<b>,<em>,<i>,<u>or<code>is shielded instead of written as Markdown wherever Markdown would not read back the same markup: an attribute, whitespace at its edge, a block anywhere inside it (a<strong>wrapping a paragraph; a<p>holding a<table>,<legend>,<option>or<optgroup>, which quirks mode allows — written as Markdown, the paragraph would split around it), nested or adjacent emphasis, emphasis, a line break or another<code>inside<code>.<b>and<i>stay<b>and<i>: the converter writes back the name of each family the record uses most and shields the other (emphasis_tags_of). Block-level elements are an explicit list, the HTML user-agent stylesheet's block, list-item and table elements (BLOCK_TAGS:p,div, headings, lists, tables,blockquote,pre,xmp…); every other element — phrasing, obsolete (strike,big,tt,font…), custom, namespaced (o:p) or unknown (<foo>) — is inline, so it never splits a paragraph. Whitespace is kept exactly: whitespace-only text with an inline element or text on both sides is a word space and travels as text (<strong>Roma</strong> <em>antigua</em>keeps its space); every other whitespace-only text — indentation, the newline between two blocks, a space at the edge of a run — is a token restored byte for byte. Inside text a newline run becomes one space, except where the line breaks are visible: under an inline style whosewhite-space(orwhite-space-collapse) keeps them (pre,pre-wrap,pre-line,break-spaces,preserve,preserve-breaks, or a multi-keyword value with one of those) each break is a token restored exactly. The nearest element that declares a valid value decides. In the browser the engine asks the CSSOM (element.style), which already applied the cascade; without one (the gate's parse5 tree)white_space_keeps_breaksreads the attribute as CSS does: comments ignored,!important(also! important) beats a normal declaration, the last valid declaration of the winning importance wins, an invalid or prefixed value (bogus,-moz-pre-wrap) is dropped as if absent, and a;inside a quoted string does not end a declaration.<pre>,<xmp>,<listing>,<plaintext>,<textarea>,<noembed>,<noframes>and<title>are restored whole (RAW_ATOM_TAGS). reaches the model as the U+00A0 character the parser reads, so nothing adds or drops one. The text's own literal*,_,`and\are tokens, like a mark: the model never sees one, so none can be read as a delimiter, deleted or moved, and there is no Markdown escaping anywhere. A run of them next to a word (2*3,lHospitalet,Roma*) is one inline token the hoisting leaves in place, so the cost is one token per run, not per character. Loose text and inline elements at the top level are bracketed by two empty block tokens, so nothing wraps them in a. Private-use characters (U+E000–E008, used by epigraphic fonts) are escaped around the converter's own stand-ins, never deleted. **Block structure comes from the source, never from the model's text**: no Markdown block syntax is written or parsed, so a translated paragraph that starts with1984.,-,#or>, or a---line, stays a paragraph of text (it used to become a list, a heading, a quote or a rule). The Markdown is cut into segments of at most 250 characters (segment_markdown, paragraph then line then sentence boundaries; a segment'ssepis the text that preceded it, so the rejoin is exact). Every block-tag edge is a mandatory cut too (block_token_cuts: before a block open or atom unless another open precedes it, after a block close or atom unless another close follows it), so each list item, cell or paragraph of a shielded container is its own segment and, once its edge tokens are hoisted, reaches the model free of structural tokens; a long item is still cut a few sentences at a time.|is ordinary text: no line is protected from a cut except a link and inline code, and a backtick range is never a reason to skip a block cut. Each segment becomes a block (build_blocks): emphasis balanced across the cut, the tokens at its edges **hoisted** out (re-attached unchanged after translation, so most marks never reach the model) and the rest renumbered from 1, with arestore_mapback to the document numbering. A source whose own text already looks like a token ([[[3]]],[[3]]`, or brackets that would form one around a shielded tag) is refused before the model starts. - The worker's block loop (
block_runner.js, model-free so it can be tested) sends the model the segment and nothing else: TranslateGemma translates whatever is in its text field, so an instruction or a correction would come back translated, into the record. For each block it unwraps fences or a preamble, normalises tokens the model mangled ([[5]],[[[ 5 ]]], escaped brackets, localised digits) and removes tokens the model invented. A quadruple-bracket shape is read from the segment: where the segment carries the text's own[token]([*],[<img>]), every[[[[n]]]]the model writes is brackets around a token; elsewhere it is a mangled token. Before anything is conformed, the raw answer is searched for Dédalo marks with the main thread'str.jspatterns (sent with the blocks asmark_patterns, since the worker never imports the Dédalo runtime;run_blocksrefuses to start without them): every real mark of the segment is a token, so a mark in the answer was written by the model and the block fails (added_mark). Conforming would otherwise delete the_of[TC_…_TC]and save it as mangled text. Every*,_and`left in the answer is then a delimiter the model wrote, since the text's own are tokens.conform_delimiterskeeps, of each kind, only the pairs that read as emphasis or code (code spans first, a*inside one being code's text; an opener has a non-space after it, a closer a non-space before it, and two delimiters with nothing between never pair), and never more than the segment has. Delimiters that do not read as a pair are never paired by position:Rome* and *Ostiasaves asRome and Ostia, neverRome<em> and </em>Ostia. Every deleted delimiter is reported with the invented tokens (residual), so a save that lost one carries a warning. When the model's reading pairs of a kind outnumber the segment's, which one is the source's would be a guess: the block is asked once more with sampling (EMPHASIS_RETRY) and, still too many, fails (added_emphasis). A kind the segment has none of is simply deleted. Each kept span is then compared with its source span (the k-th of its kind, in reading order — never by position, since a translation reorders words): it was moved when an edge the source had at a word boundary falls inside a word, when the share of the segment's words it covers is outside ½–2 × the source span's, or when an item both texts carry (a mark, a name, a number, a bracket) crossed its edge. A colon, comma or stop touching an edge is catalogue house style and never counts (**Anverso:**→**Obverse**:,*plata,*→*silver*,), except in code, where punctuation is code. A moved span is saved with a warning (emphasis_moved, labelemphasis_moved), never refused: the span is the model's. A word in a script written without spaces (Chinese, Japanese, Thai…) is one character and no edge falls inside it. So2*3*4 gis never saved as234 g,l`Hospitaletnever gains a<code>, and emphasis only ever spans letters the model delimited as a pair. A backslash the model writes is a character of its answer. A block fails, so the run is refused, when its answer wrote a Dédalo mark (added_mark) or more emphasis than the segment has (added_emphasis), wrote markup the segment did not carry (added_markup:<br>,<b>…</b>, a second<p>; tag-shaped text of the record itself is allowed), lost its text (lost_text: nothing but tokens and whitespace for a segment with text; a short answer is still an answer, so不明for a long phrase passes), looped (repetition), or stopped at the generation limit (truncated: themax_new_tokensbudget used up without the end token, counted by the translator's streamer). The worker throws these as{code, detail}(BlockError,BLOCK_ERROR_CODES) and the main thread words them from the tool labelsblock_<code>(block_failure_text), with the English text as the fallback. An answer that ends fewer sentences than its segment (sentences_short) is saved with a warning: it may be cut short or have dropped a sentence. An abbreviation's period is no sentence end, decided by context: a token with dotted internals (a.C.,d.C.,p.ej.) always; a stated list of titles and reference abbreviations a capital may follow (Dr.,Sr.,ca.,cf.,fig.,núm., … —ABBREVIATIONSinmarkdown_utils.js); a token of at most three letters whose period is followed by a digit, a lower-case letter, a closing bracket, a dash, a comma or a semicolon. A period at the end of the text, or followed by a capital or a mark, is a sentence end (Es mío.,Fin.), so27 a.C.–14 d.C.→27 BC–AD 14stays clean. A line break the model wrote into a segment that had none becomes one space (collapse_model_breaks), so a shielded item never comes back as two paragraphs. A<p>…</p>wrapper the model added around its answer is removed (strip_added_paragraph);<p>text the source itself carries is kept. Where a cut fell inside emphasis, the delimiters balancing added at the two halves' meeting point are removed when the halves are rejoined, so the emphasis comes back as one run. A repetition loop (a phrase cycle the source does not have — a record that repeats itself is not a loop) is retried with a stiffer repetition penalty, then with sampling; a block still looping is lost. Tokens still missing are placed byrepair_placeholders(open/close pairs first, then sentence-aligned placement) and reported; a token the model wrote twice has every copy removed (which one is right is unknowable). A cancel that arrives during the last block ends the run as cancelled, never as finished. - Back on the main thread the translated Markdown becomes HTML with every character the model wrote escaped — a translated
<script>is stored as text — then each token is restored exactly once, inverted shielded-tag pairs and inverted index/reference pairs (reorder_inverted_pairs) are put back in order, andvalidate_translationcounts the source's marks against the result's. - What is saved, and what is refused. The run refuses — saves nothing, restores the target's stored value and rejects — when a block failed, when the result is empty, when any mark or shielded tag is missing, could not be placed, was duplicated or was not in the source, when a mark ended up inside markup instead of text, when the structural tags (paragraphs, list items, cells) came back in a different order than the source (
structure_out_of_order, labeltags_out_of_order), when tags came back wrongly nested — a close inside another open tag, among the shielded tags and the<p>/<strong>/<b>/<em>/<i>/<u>/<code>the converter writes (tags_crossed, same label name), or when the result is a repetition loop (far longer than its source). The panel then shows Translation needs review before saving with one line per kind. A mark the engine had to reposition or reorder, or a token it had to remove, is saved, with Translation saved — check the marks and the same per-kind lines, and the call resolves{result: true, msg: 'OK. Translation saved with warnings', warnings: <report>}instead of{result: true, msg: 'OK. Translation completed', warnings: null}; there is no accept/discard step. A model that cannot run here (unsupported language pair or a pair model not installed in the store —unsupported_pair; no WebGPU —needs_webgpu; too large —model_too_large) resolves{result: false, code}with a message, and nothing is saved; the try a smaller model advice names only offered models that run without WebGPU (block_runner.jssmaller_model_advice, from thealternativesthe panel sends). The same soft refusal comes before the worker starts when no model is offered (no_model, labeltranslation_no_model) or when the source or target language has no locale code in the language registry (unsupported_lang, labeltranslation_lang_unmapped;lg-nolanis one) — such a language is never translated as English. Lost emphasis (bold, italic) is reported, never a reason to refuse. An answer with fewer sentences than its source is saved with the warningsentences_short(%s passages came back with fewer sentences than the source), and bold, italic or code the model put on other words withemphasis_moved(%s passages have bold, italic or code on other words than the source). The labels (translation_*,marks_*,emphasis_lost,engine_*, …) are tool-local, inregister.jsondd1372, in every catalog language. Gates:test/unit/tool_lang_identity_roundtrip.test.ts(the IDENTITY gate: the real pipeline —prepare_translation, the block loop,finish_translation— with a model that returns its input, over a corpus of heritage HTML and a seeded fuzz leg; it asserts the saved value equals the source up to the browser serialiser's normal form and the newline rule above, that no structural token reaches the model, and that nothing is refused; and its DEVIANT-model leg — models that drop or add backslashes, answer nothing or only tokens, write HTML, break lines, add or drop backticks and asterisks, write stars at word ends, swap, drop, repeat or move tokens and delimiters, reverse words — asserting every run is either refused or saves the model's letters in the source's elements, with no literal metacharacter deleted or invented, no markup as visible text, every emphasis element spanning exactly letters the model delimited, no emphasis lost unless the model dropped its reading pairs, and, on a save without warnings, emphasis only where the source had it or where the model wrote a reading pair while writing no more than its segment had, on its source span's words (edges, coverage, shared items: its own statement of the three checks); the white-space answers are a stated table, never a parser; DOM bytest/helpers/parse5_dom.ts),test/unit/tool_lang_placeholder_repair.test.ts(the block loop, the repair, segmentation, escaping, the catalogue) and the client suitetest_tool_lang_browser_translation(the whole driver against a stand-in model, and the identity cases in a real browser).
Server (tools/tool_lang/server/index.ts, delegating to the shared core src/core/tools/translation.ts::runAutomaticTranslation): the single action automatic_translation:
- Gates imperatively —
apiActionsdeclarespermission: null(the shared core's ownassertActionPermissioncall does the real gating, reusing therecord/2 kind against{section_tipo, section_id}). Note therecordgate's scope: it always checks the permission level on(section_tipo, section_tipo)— the section-level permission — not on the specific component tipo. A profile that grants section-level write but denies write specifically on this component (or vice versa) is not distinguished by this gate. The gate also asserts the record is in the caller's project scope. - Loads the tool config (
getToolConfig('tool_lang')) and finds the requested engine's entry byname; refuses if itsuri/keyis missing. - Reads the component's source-lang value and translates it.
babel(the default) is a SSRF-guarded HTTP call to the configured Apertium-based Babel service (babelProvider, direction mapping likesp-en); other server-side engines resolve through the same provider-seam contract (resolveTranslationProvider);browser_transformeris rejected on the server (client-only). - Writes the translated value onto the target-lang instance of the same component and surfaces a "Quota exceeded"-style message when the engine reports it. A result with no visible text for a source item that has some (
isEmptyTranslation; markup is not text) is refused: nothing is written and the request fails withtranslation.empty_result(what Babel answers for an unsupported language pair; WC-2026-11-10-translation-empty-result). Both tools show translation refusals in their own panel (translation.*→silentpage policy, registered bytools/tool_lang/js/translator_engine_select.js, the engine picker both tools share).
Actions & options
apiActions = { automatic_translation: { permission: null, handler: ... } } — the gate lives inside the shared runAutomaticTranslation core, not the dispatcher's declarative layer — see the note above. There is no backgroundRunnable; the request runs synchronously with a long client timeout. Copy-to-target and the in-browser engine are client-only and reach no server action.
| Action | Permission gate | Background | Reads from options |
|---|---|---|---|
automatic_translation |
permission: null + imperative record/2 gate (section-level permission + record-in-scope) on {section_tipo, section_id}, inside runAutomaticTranslation; refuses if component_tipo, section_tipo or target_lang missing |
no | see below |
Options read by automatic_translation:
| Option | Type | Meaning |
|---|---|---|
component_tipo |
string (req.) | The text component to translate. Missing → invalid_request. |
section_tipo |
string (req.) | Section type of the component. Missing → invalid_request. Write-gated. |
section_id |
int | Record id holding the component. When present, adds the per-record scope assert and selects the exact record's data. |
source_lang |
string | Source language code; defaults to DEDALO_DATA_LANG. Read side. |
target_lang |
string | Target language code; the translated values are saved here. |
translator |
string | Engine name resolved against the tool config ('babel' default, 'google_translation' not implemented, 'browser_transformer' server-rejected). |
config |
object | Optional translator-config object passed from the client; the server prefers the stored tool config (dd996/dd1633). |
Response: { result: bool, msg: string, errors: string[] }, plus a debug object (translated_data, raw_result) when SHOW_DEBUG===true.
How it is registered & surfaced
tools/tool_lang/register.json is a column-keyed dump (string/relation/misc/… keyed by component tipo — a seeded matrix-row snapshot, not a hand-authored file); importTools() passes it through as-is (see register.json reference). What it carries:
dd1326name =tool_lang;dd1327version (2.6.0);dd1328minimum Dédalo version (6.9.0);dd1644developer (Dédalo team).dd999/dd1633config (default + sample):translator_config(client:false— the per-engineuri+keysecrets, kept server-side) andtranslator_engine(client:true— the engine picker list: Babel + Google asserver, "Local AI translator" asbrowser, with itsmodelscatalogue). Per-install overrides live in the Tools configuration section (dd996) under a record namedtool_lang.dd1335properties ={ "open_as": "window" }→ the tool opens in its own window.dd1372labels supply the localized UI strings (automatic_translation,source_lang,target_lang,copy_to_target, progress/status strings, …) across all project languages.
Surfacing (in getElementTools, src/core/tools/registry.ts): the register.json declares no affected_models / affected_tipos and no show_in_inspector / show_in_component flags. tool_lang is therefore attached the element-properties way: a text component whose ontology properties->tool_config->tool_lang names the tool (and supplies the ddo_map with the main_element / target_component / status roles) gets the Translation button. In other words it appears inline on the configured text component, not as a blanket section/area tool.
Examples
Client-side request built by tool_lang.js::automatic_translation_server and dispatched through dd_tools_api:
const source = create_source(self, 'automatic_translation') // → tool_lang::automatic_translation
const rqo = {
dd_api : 'dd_tools_api',
action : 'tool_request',
source : source,
options : {
source_lang : 'lg-spa', // translate FROM Spanish
target_lang : 'lg-eng', // …INTO English
component_tipo : self.main_element.tipo, // e.g. the Description component
section_id : self.main_element.section_id,
section_tipo : self.main_element.section_tipo,
translator : 'babel', // engine name from tool config
config : self.context.config
}
}
// long timeout: machine translation of a long text can take a while
const response = await data_manager.request({ body: rqo, retries: 5, timeout: 3600 * 1000 })
// response → { result:true, msg:'OK. Request done [automatic_translation]', errors:[] }
Engine selection (the data the client reads from translator_engine, client:true):
[
{ "name": "babel", "type": "server", "label": "Babel" },
{ "name": "google_translation", "type": "server", "label": "Google translator" },
{ "name": "browser_transformer", "type": "browser", "label": "Local AI translator" }
]
A server engine triggers the automatic_translation API action above; a browser engine runs the in-page Web Worker model and never calls the server. The matching secret per server engine lives in translator_config (client:false):
{ "name": "babel", "uri": "https://babel.render.es/babel_engine/", "key": "•••" }
The browser model catalogue
The Local AI translator runs one of these models in the browser. The list lives in the browser engine's models array in register.json (dd999 and dd1633); an installation narrows or extends it in its own tool configuration record.
name |
Model (hub id) | Runs on | Quantisation | Licence (pinned) | Offered by default |
|---|---|---|---|---|---|
qwen |
onnx-community/Qwen3-4B-Instruct-2507-ONNX |
WebGPU only | q4f16 |
Apache-2.0 | yes (the default) |
translategemma |
onnx-community/translategemma-text-4b-it-ONNX |
WebGPU only | q4 |
Gemma Terms of Use | yes |
nllb |
Xenova/nllb-200-distilled-600M |
WebGPU or CPU | q8 |
CC-BY-NC-4.0 | no |
madlad |
Kutalia/madlad400-3b-mt-onnx |
WebGPU only | q8 |
Apache-2.0 | yes |
opus |
Xenova/opus-mt-{src}-{tgt} (one model per language pair) |
WebGPU or CPU | q8 |
Apache-2.0 (en→de: CC-BY-4.0) | yes |
- Pins. Each model is pinned by the hub's commit
revisionand every file's sha256 insrc/core/ai/model_pins.json, together with the licence record the pin procedure read from the model cards (card/upstream,src/core/ai/model_pins.ts::licenceProblemsvalidates it). The opus pairs are the pairs the hub actually serves among the languages listed in the file'sexpansionsentry. A file without a pin is never fetched or served. - Not offered by default. A model whose licence restricts the use is still listed, with
offered_by_default: falseand anot_offered_reason; the selector leaves it out.nllbis licensed for non-commercial use only. An installation that has confirmed its use is non-commercial enables it in its tool configuration record by settingoffered_by_default: trueon that entry.offered_by_defaultis a strict boolean: absent ortrueoffers the model, any other value ("false",0,null) does not, and no model at all is never offered (browser_models.jsis_offered). - Seeding. The weights are not shipped. An administrator downloads the chosen models into the model store with
bun run scripts/fetch_ai_models.ts <model id>(--listshows the catalogue and what is already in the store, marking a model that is not offered[not offered: <reason>]).--allfetches every offered model and names the ones it skipped; a model that is not offered is fetched only when named explicitly.--dry-runprints what would be fetched after the same catalogue and pin lookup as a real run, so an id in no catalogue or without a pin is refused there too;--allskips a model without a pin and says so. An unknown--option, or--storewithout a directory, exits 2 with nothing fetched. A large translator is about 3 GB; an opus pair about 115 MB. - Quantisation. The store serves only pinned files, so a model runs at the quantisation it is pinned at. To offer a second one (TranslateGemma at
q8), the entry lists both indtypesand each must be pinned; until then the Quality selector does not appear. - CPU fallback. A model marked WebGPU-only refuses to start without WebGPU (
needs_webgpu) instead of loading a multi-gigabyte model into the CPU backend; a small model (nllb,opus) falls back to the CPU when WebGPU fails.
Untested against the real models
The segmentation, hoisting, repair, repetition guard and refusals are tested against a stand-in model: the gates prove what the engine does with whatever a model returns, not how well a given model translates. None of the catalogue models has been run by the test suite (no GPU in CI). Before offering a model to cataloguers, check it by hand:
- Seed it (
bun run scripts/fetch_ai_models.ts <model id>) and open a record whose text field holds index marks, a time code, bold text and a<sup>or a link, in a browser with WebGPU. - Run Automatic translation into two languages with that model selected.
- Compare the source and the target: every mark present once and around the right words, the formatting kept, no repeated phrases. A run the engine refuses or saves with warnings shows why in the panel.
Related
tool_lang_multi— translate one source component into several target languages in a single run; its ownserver/index.tsaction calls the same sharedrunAutomaticTranslation(ctx, 'tool_lang')core (so behavior and config resolution are identical totool_lang's) and shares the in-browser engine (tools/tool_lang/js/browser_translation.js).- tool_transcription / tool_subtitles — other text/media-content tools that, like
tool_lang, can use external/AI engines (Babel, Whisper). - tool_export · Exporting data — the read-only counterpart for getting (translated) data out of a section.
- Creating new tools · Server contract — the tool model,
apiActions, permission gates and config resolution this page builds on. - Source:
tools/tool_lang/server/index.ts, the shared translation coresrc/core/tools/translation.ts(runAutomaticTranslation,babelProvider,resolveTranslationProvider),tools/tool_lang/js/{tool_lang,render_tool_lang,browser_translation,placeholders,block_runner,markdown_utils,browser_models,translator_engine_select}.js,tools/tool_lang/translators/browser_transformer/browser_transformer.js,src/core/ai/model_pins.json,tools/tool_lang/register.json.