# locize/xliff architecture

> Architecture diagram of the GitHub repository locize/xliff, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/locize/xliff
- Repository: https://github.com/locize/xliff

## Overview

xliff is a JavaScript library for converting between XLIFF documents and a structured JavaScript resource model, with support for XLIFF 1.2 and 2.x, inline elements, and source/target extraction. The main workflow starts with a caller selecting a conversion or construction API, then parses or builds the version-specific document representation. Inline values and XML structure are handled by shared internal layers. The graph reflects README-documented capabilities and shown imports; some converter internals were not excerpted, so uncertain links are omitted.

Main entry points: [`lib/index.js`](https://github.com/locize/xliff/blob/master/lib/index.js) (API exports), [`lib/inline-elements/flatten.js`](https://github.com/locize/xliff/blob/master/lib/inline-elements/flatten.js) (Inline flattening), [`lib/js2xliff.js`](https://github.com/locize/xliff/blob/master/lib/js2xliff.js) (JS to XLIFF 2.x), [`lib/jsToXliff12.js`](https://github.com/locize/xliff/blob/master/lib/jsToXliff12.js) (JS to XLIFF 1.2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public APIs"]
  node_exports["API exports<br/>[index.js]"]
  node_createjs["Build JS model<br/>[createjs.js]"]
  node_createxliff["Build XLIFF 2.x<br/>[createxliff.js]"]
  node_createxliff12["Build XLIFF 1.2<br/>[createxliff12.js]"]
  node_sourceofjs["Extract sources<br/>[sourceOfjs.js]"]
  node_targetofjs["Extract targets<br/>[targetOfjs.js]"]
end

subgraph group_v2["XLIFF 2.x"]
  node_decode2["XLIFF 2.x to JS<br/>[xliff2js.js]"]
  node_encode2["JS to XLIFF 2.x<br/>[js2xliff.js]"]
end

subgraph group_v12["XLIFF 1.2"]
  node_decode12["XLIFF 1.2 to JS<br/>[xliff12ToJs.js]"]
  node_encode12["JS to XLIFF 1.2<br/>[jsToXliff12.js]"]
end

subgraph group_shared["Shared conversion layers"]
  node_inlineflatten["Inline flattening<br/>[flatten.js]"]
  node_inlinefactory["Inline element factory"]
  node_elementtypes["Element type names<br/>[ElementTypes.js]"]
  node_types2["2.x tag mappings<br/>[ElementTypes2.js]"]
  node_types12["1.2 tag mappings<br/>[ElementTypes12.js]"]
  node_tagmaps["Tag lookup<br/>[typeToTagMaps.js]"]
  node_xmlwrite["XML object builder<br/>[objectToXml.js]"]
  node_xmlread["XML value reader<br/>[xmlToObject.js]"]
  node_escape["XML escaping<br/>[escape.js]"]
  node_modelhelper["Model traversal<br/>[ofjs.js]"]
end

node_caller(("Library caller"))

node_caller -->|"uses"| node_exports
node_exports -->|"exports"| node_decode2
node_exports -->|"exports"| node_decode12
node_exports -->|"exports"| node_encode2
node_exports -->|"exports"| node_encode12
node_exports -->|"exports"| node_createjs
node_exports -->|"exports"| node_createxliff
node_exports -->|"exports"| node_createxliff12
node_exports -->|"exports"| node_sourceofjs
node_exports -->|"exports"| node_targetofjs
node_exports -->|"exports"| node_inlineflatten
node_createxliff -->|"calls"| node_createjs
node_createxliff -->|"calls"| node_encode2
node_createxliff12 -->|"calls"| node_createjs
node_createxliff12 -->|"calls"| node_encode12
node_sourceofjs -->|"delegates"| node_modelhelper
node_targetofjs -->|"delegates"| node_modelhelper
node_encode2 -->|"uses mappings"| node_types2
node_encode2 -->|"builds XML"| node_xmlwrite
node_encode2 -->|"unflattens strings"| node_inlineflatten
node_encode2 -->|"escapes values"| node_escape
node_encode12 -->|"uses mappings"| node_types12
node_encode12 -->|"builds XML"| node_xmlwrite
node_encode12 -->|"unflattens strings"| node_inlineflatten
node_encode12 -->|"escapes values"| node_escape
node_xmlwrite -->|"maps tags"| node_tagmaps
node_decode2 -->|"uses mappings"| node_types2
node_decode2 -->|"reads XML values"| node_xmlread
node_decode2 -->|"unflattens values"| node_inlineflatten
node_decode12 -->|"uses mappings"| node_types12
node_decode12 -->|"reads XML values"| node_xmlread
node_decode12 -->|"unflattens values"| node_inlineflatten
node_xmlread -->|"maps tags"| node_tagmaps
node_inlineflatten -->|"constructs elements"| node_inlinefactory
node_inlineflatten -->|"uses types"| node_elementtypes
node_types2 -->|"uses types"| node_elementtypes
node_types2 -->|"builds elements"| node_inlinefactory
node_types12 -->|"uses types"| node_elementtypes
node_types12 -->|"builds elements"| node_inlinefactory

click node_exports "https://github.com/locize/xliff/blob/master/lib/index.js"
click node_createjs "https://github.com/locize/xliff/blob/master/lib/createjs.js"
click node_createxliff "https://github.com/locize/xliff/blob/master/lib/createxliff.js"
click node_createxliff12 "https://github.com/locize/xliff/blob/master/lib/createxliff12.js"
click node_sourceofjs "https://github.com/locize/xliff/blob/master/lib/sourceOfjs.js"
click node_targetofjs "https://github.com/locize/xliff/blob/master/lib/targetOfjs.js"
click node_decode2 "https://github.com/locize/xliff/blob/master/lib/xliff2js.js"
click node_encode2 "https://github.com/locize/xliff/blob/master/lib/js2xliff.js"
click node_decode12 "https://github.com/locize/xliff/blob/master/lib/xliff12ToJs.js"
click node_encode12 "https://github.com/locize/xliff/blob/master/lib/jsToXliff12.js"
click node_inlineflatten "https://github.com/locize/xliff/blob/master/lib/inline-elements/flatten.js"
click node_inlinefactory "https://github.com/locize/xliff/blob/master/lib/inline-elements/makeInlineElement.js"
click node_elementtypes "https://github.com/locize/xliff/blob/master/lib/inline-elements/ElementTypes.js"
click node_types2 "https://github.com/locize/xliff/blob/master/lib/inline-elements/ElementTypes2.js"
click node_types12 "https://github.com/locize/xliff/blob/master/lib/inline-elements/ElementTypes12.js"
click node_tagmaps "https://github.com/locize/xliff/blob/master/lib/inline-elements/typeToTagMaps.js"
click node_xmlwrite "https://github.com/locize/xliff/blob/master/lib/xml-js/objectToXml.js"
click node_xmlread "https://github.com/locize/xliff/blob/master/lib/xml-js/xmlToObject.js"
click node_escape "https://github.com/locize/xliff/blob/master/lib/util/escape.js"
click node_modelhelper "https://github.com/locize/xliff/blob/master/lib/ofjs.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_exports,node_createjs,node_createxliff,node_createxliff12,node_sourceofjs,node_targetofjs toneBlue
class node_decode2,node_encode2 toneAmber
class node_decode12,node_encode12 toneMint
class node_inlineflatten,node_inlinefactory,node_elementtypes,node_types2,node_types12,node_tagmaps,node_xmlwrite,node_xmlread,node_escape,node_modelhelper toneRose
class node_caller toneIndigo
```

## Components

### Public APIs

- [API exports](https://github.com/locize/xliff/blob/master/lib/index.js): `lib/index.js`
- [Build JS model](https://github.com/locize/xliff/blob/master/lib/createjs.js): `lib/createjs.js`
- [Build XLIFF 2.x](https://github.com/locize/xliff/blob/master/lib/createxliff.js): `lib/createxliff.js`
- [Build XLIFF 1.2](https://github.com/locize/xliff/blob/master/lib/createxliff12.js): `lib/createxliff12.js`
- [Extract sources](https://github.com/locize/xliff/blob/master/lib/sourceOfjs.js): `lib/sourceOfjs.js`
- [Extract targets](https://github.com/locize/xliff/blob/master/lib/targetOfjs.js): `lib/targetOfjs.js`

### XLIFF 2.x

- [XLIFF 2.x to JS](https://github.com/locize/xliff/blob/master/lib/xliff2js.js): `lib/xliff2js.js`
- [JS to XLIFF 2.x](https://github.com/locize/xliff/blob/master/lib/js2xliff.js): `lib/js2xliff.js`

### XLIFF 1.2

- [XLIFF 1.2 to JS](https://github.com/locize/xliff/blob/master/lib/xliff12ToJs.js): `lib/xliff12ToJs.js`
- [JS to XLIFF 1.2](https://github.com/locize/xliff/blob/master/lib/jsToXliff12.js): `lib/jsToXliff12.js`

### Shared conversion layers

- [Inline flattening](https://github.com/locize/xliff/blob/master/lib/inline-elements/flatten.js): `lib/inline-elements/flatten.js`
- [Inline element factory](https://github.com/locize/xliff/blob/master/lib/inline-elements/makeInlineElement.js): `lib/inline-elements/makeInlineElement.js`
- [Element type names](https://github.com/locize/xliff/blob/master/lib/inline-elements/ElementTypes.js): `lib/inline-elements/ElementTypes.js`
- [2.x tag mappings](https://github.com/locize/xliff/blob/master/lib/inline-elements/ElementTypes2.js): `lib/inline-elements/ElementTypes2.js`
- [1.2 tag mappings](https://github.com/locize/xliff/blob/master/lib/inline-elements/ElementTypes12.js): `lib/inline-elements/ElementTypes12.js`
- [Tag lookup](https://github.com/locize/xliff/blob/master/lib/inline-elements/typeToTagMaps.js): `lib/inline-elements/typeToTagMaps.js`
- [XML object builder](https://github.com/locize/xliff/blob/master/lib/xml-js/objectToXml.js): `lib/xml-js/objectToXml.js`
- [XML value reader](https://github.com/locize/xliff/blob/master/lib/xml-js/xmlToObject.js): `lib/xml-js/xmlToObject.js`
- [XML escaping](https://github.com/locize/xliff/blob/master/lib/util/escape.js): `lib/util/escape.js`
- [Model traversal](https://github.com/locize/xliff/blob/master/lib/ofjs.js): `lib/ofjs.js`

### Other components

- **Library caller**

## Connections

- Library caller → API exports: uses (evidence: `README.md`)
- API exports → XLIFF 2.x to JS: exports (evidence: `lib/index.js`)
- API exports → XLIFF 1.2 to JS: exports (evidence: `lib/index.js`)
- API exports → JS to XLIFF 2.x: exports (evidence: `lib/index.js`)
- API exports → JS to XLIFF 1.2: exports (evidence: `lib/index.js`)
- API exports → Build JS model: exports (evidence: `lib/index.js`)
- API exports → Build XLIFF 2.x: exports (evidence: `lib/index.js`)
- API exports → Build XLIFF 1.2: exports (evidence: `lib/index.js`)
- API exports → Extract sources: exports (evidence: `lib/index.js`)
- API exports → Extract targets: exports (evidence: `lib/index.js`)
- API exports → Inline flattening: exports (evidence: `lib/index.js`)
- Build XLIFF 2.x → Build JS model: calls (evidence: `lib/createxliff.js`)
- Build XLIFF 2.x → JS to XLIFF 2.x: calls (evidence: `lib/createxliff.js`)
- Build XLIFF 1.2 → Build JS model: calls (evidence: `lib/createxliff12.js`)
- Build XLIFF 1.2 → JS to XLIFF 1.2: calls (evidence: `lib/createxliff12.js`)
- Extract sources → Model traversal: delegates (evidence: `lib/sourceOfjs.js`)
- Extract targets → Model traversal: delegates (evidence: `lib/targetOfjs.js`)
- JS to XLIFF 2.x → 2.x tag mappings: uses mappings (evidence: `lib/js2xliff.js`)
- JS to XLIFF 2.x → XML object builder: builds XML (evidence: `lib/js2xliff.js`)
- JS to XLIFF 2.x → Inline flattening: unflattens strings (evidence: `lib/js2xliff.js`)
- JS to XLIFF 2.x → XML escaping: escapes values (evidence: `lib/js2xliff.js`)
- JS to XLIFF 1.2 → 1.2 tag mappings: uses mappings (evidence: `lib/jsToXliff12.js`)
- JS to XLIFF 1.2 → XML object builder: builds XML (evidence: `lib/jsToXliff12.js`)
- JS to XLIFF 1.2 → Inline flattening: unflattens strings (evidence: `lib/jsToXliff12.js`)
- JS to XLIFF 1.2 → XML escaping: escapes values (evidence: `lib/jsToXliff12.js`)
- XML object builder → Tag lookup: maps tags (evidence: `lib/xml-js/objectToXml.js`)
- XLIFF 2.x to JS → 2.x tag mappings: uses mappings (evidence: `lib/xliff2js.js`)
- XLIFF 2.x to JS → XML value reader: reads XML values (evidence: `lib/xliff2js.js`)
- XLIFF 2.x to JS → Inline flattening: unflattens values (evidence: `lib/xliff2js.js`)
- XLIFF 1.2 to JS → 1.2 tag mappings: uses mappings (evidence: `lib/xliff12ToJs.js`)
- XLIFF 1.2 to JS → XML value reader: reads XML values (evidence: `lib/xliff12ToJs.js`)
- XLIFF 1.2 to JS → Inline flattening: unflattens values (evidence: `lib/xliff12ToJs.js`)
- XML value reader → Tag lookup: maps tags (evidence: `lib/xml-js/xmlToObject.js`)
- Inline flattening → Inline element factory: constructs elements (evidence: `lib/inline-elements/flatten.js`)
- Inline flattening → Element type names: uses types (evidence: `lib/inline-elements/flatten.js`)
- 2.x tag mappings → Element type names: uses types (evidence: `lib/inline-elements/ElementTypes2.js`)
- 2.x tag mappings → Inline element factory: builds elements (evidence: `lib/inline-elements/ElementTypes2.js`)
- 1.2 tag mappings → Element type names: uses types (evidence: `lib/inline-elements/ElementTypes12.js`)
- 1.2 tag mappings → Inline element factory: builds elements (evidence: `lib/inline-elements/ElementTypes12.js`)
