XML format (.xml)
The XML format reads generic XML documents, extracts the text of configured elements and attributes as translatable blocks, and writes the translations back while preserving the surrounding markup. Inline elements become inline codes within a block, so formatting tags survive translation.
Extraction is rule-driven. The simple lists (translatableElements,
translatableAttributes, inlineElements, excludedElements) cover most
cases. The advanced elements and attributes maps express richer,
ITS-style rules with attribute conditions, ID and translatable-attribute
mappings, and explicit include/exclude behaviour. When no translatable
elements are listed, all text content is treated as translatable; set
excludeByDefault to invert that and include only what rules opt in.
How kapi reads it
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
attributes | object | Avanserte attributtspesifikke behandlingsregler med elementomfangsbegrensninger | |
blockTypeMap | object | Tilordning av elementnavn til blokktype-strenger for semantisk typeannotering | |
codeFinderRules | array | Regex-mønstre som samsvarer med innebygde koder i oversettbar tekst | |
elements | object | Avanserte elementspesifikke behandlingsregler med betingelser, innebygd merking og oversettbare attributttilordninger | |
excludeByDefault | boolean | false | Ekskluder alle elementer med mindre de eksplisitt er inkludert av en elementregel med INCLUDE |
excludedElements | array | Elementnavn hvis innhold er utelatt fra uttrekk | |
extractNonTranslatableContent | boolean | true | Hvis sann (standard), vises ikke-oversettbart kontekstuelt innhold, som tekst i elementer utelukket fra hvitelisten og verbatim kode/pre-undertrær, som innholdsblokker (synlig for innhenting/LLM-konsumenter, hoppes over av maskinoversettelse) i stedet for å skjules i skjelettet. Deaktiver for å beholde det i skjelettet. |
groupElements | array | Elementnavn som produserer gruppe-/laggrenser i utdataene | |
idAttributes | array | Attributtnavn brukt til å hente blokk-ID-er fra elementer | |
inlineElements | array | Elementnavn behandlet som innebygde (spenn i tekst) i stedet for blokknivå | |
preserveWhitespace | boolean | false | Bevar original mellomrom i tekstinnhold i stedet for å komprimere det |
preserveWhitespaceElements | array | Elementnavn som bevarer mellomrom uavhengig av den globale innstillingen | |
subfilters | array | Array med {pattern, format}-tilordninger for innebygd innhold. Mønstre bruker punktseparerte elementstier med glob-støtte. | |
translatableAttributes | array | Attributtnavn som kan oversettes på tvers av alle elementer | |
translatableElements | array | Elementnavn hvis tekstinnhold er oversettbart. Hvis tom, er alt tekstinnhold oversettbart. | |
useCodeFinder | boolean | false | Aktiver regex-basert gjenkjenning av innebygde koder i oversettbar tekst |
Configure it live
Examples
Extract specific elements
Translate only title and para text, treating b and i as inline.
translatableElements:
- title
- para
inlineElements:
- b
- i
Translatable attributes
Extract title and alt attribute values across all elements.
translatableAttributes:
- title
- alt
Conditional extraction with rules
Include only div elements whose translate attribute is yes.
excludeByDefault: true
elements:
div:
ruleTypes:
- INCLUDE
conditions:
- translate
- EQUALS
- "yes"
Processing notes
Inline elements become inline codes within blocks; block-level elements form the surrounding structure.
Element rules with
INCLUDE/EXCLUDEcombine withexcludeByDefaultto give fine control over which content is extracted.
Limitations
This is a generic XML reader; for specific XML dialects (such as RESX) start from a tailored rule set rather than the bare defaults.
Element and attribute names in advanced rules wrapped in single quotes are treated as anchored regular expressions.
← Back to the Format Reference