apply_segments
Restore translated sentences into their original data module while keeping the DMC and changing only the language. It verifies the result, rejects unknown or mismatched segments, and writes only when requested.
Instructions
Put translated sentences back into the data module they were taken from. The output has the same DMC with only the language changed (issueInfo too if given). It stops with error.code "skeleton-mismatch" when the data module changed since extract_segments (skeletonHash). A segment whose id is unknown, duplicated, or whose {n} placeholders do not match is not applied and is listed in unapplied[] (the original sentence stays). The result is verified. Writes only when write is true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xml | No | An existing document as an XML string (alternative to path; max 5 MB). Not for XML you wrote yourself: build new data modules with build_data_module. | |
| path | No | File path of the document. | |
| write | No | Write the result into the CSDB (the first folder of csdbDirs / S1000D_CSDB_DIR). Default false: the XML is only returned. Nothing is written when the XML is not valid against the XSD unless allowInvalid is true. | |
| csdbDirs | No | CSDB folders (in addition to S1000D_CSDB_DIR) used to resolve references, find BREX and number new objects. The FIRST folder is also where write: true writes. | |
| language | Yes | Target language written to dmIdent/language. | |
| maxFixes | No | Cap on the remaining fixes listed in the response (default 50). | |
| segments | Yes | The translated sentences, by segment id. | |
| issueInfo | No | Issue of the translated data module (default: same as the source). | |
| overwrite | No | With write: true, replace a file of the same name. Default false: an existing file is left alone and reported as write-conflict. | |
| allowInvalid | No | With write: true, write even when verification.schema.state is "invalid". Default false. | |
| skeletonHash | Yes | The skeletonHash returned by extract_segments. |