Gå til hovedinnhold

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.

IDxml
SourceBuilt-in
Extensions.xml
MIME Typestext/xml, application/xml
CapabilitiesRead + Write

How kapi reads it

Parameters

ParameterTypeDefaultDescription
attributesobjectAvanserte attributtspesifikke behandlingsregler med elementomfangsbegrensninger
blockTypeMapobjectTilordning av elementnavn til blokktype-strenger for semantisk typeannotering
codeFinderRulesarrayRegex-mønstre som samsvarer med innebygde koder i oversettbar tekst
elementsobjectAvanserte elementspesifikke behandlingsregler med betingelser, innebygd merking og oversettbare attributttilordninger
excludeByDefaultbooleanfalseEkskluder alle elementer med mindre de eksplisitt er inkludert av en elementregel med INCLUDE
excludedElementsarrayElementnavn hvis innhold er utelatt fra uttrekk
extractNonTranslatableContentbooleantrueHvis 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.
groupElementsarrayElementnavn som produserer gruppe-/laggrenser i utdataene
idAttributesarrayAttributtnavn brukt til å hente blokk-ID-er fra elementer
inlineElementsarrayElementnavn behandlet som innebygde (spenn i tekst) i stedet for blokknivå
preserveWhitespacebooleanfalseBevar original mellomrom i tekstinnhold i stedet for å komprimere det
preserveWhitespaceElementsarrayElementnavn som bevarer mellomrom uavhengig av den globale innstillingen
subfiltersarrayArray med {pattern, format}-tilordninger for innebygd innhold. Mønstre bruker punktseparerte elementstier med glob-støtte.
translatableAttributesarrayAttributtnavn som kan oversettes på tvers av alle elementer
translatableElementsarrayElementnavn hvis tekstinnhold er oversettbart. Hvis tom, er alt tekstinnhold oversettbart.
useCodeFinderbooleanfalseAktiver regex-basert gjenkjenning av innebygde koder i oversettbar tekst

Configure it live

Configuration
Loading form…

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/EXCLUDE combine with excludeByDefault to 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