Building and writing an XLIFF document
import { XliffDocument, XliffFile, XliffUnit, XliffSegment, XliffSource } from "typesxliff";
const doc = new XliffDocument("2.1", "en", "es");
const file = new XliffFile("f1");
const unit = new XliffUnit("u1");
const segment = new XliffSegment("s1");
const source = new XliffSource();
source.addContent("Hello, world!");
segment.setSource(source);
unit.addItem(segment);
file.addEntry(unit);
doc.addFile(file);
doc.writeDocument('/path/to/output.xlf', true);
Built with TypesXLIFF
These tools are built on TypesXLIFF and show practical uses of the library:
A command-line tool for validating XLIFF 2.x files. It uses TypesXLIFF's object model and
isValid() methods to check structural and semantic constraints against the XLIFF 2.x
specification, and supports custom grammar catalogs for schema resolution.
npm install -g xliff-validation
xliffvalidator -xliff file.xlf
A TypeScript library and command-line tool for extracting term candidates from XLIFF 2.x files using
the YAKE! statistical algorithm. Supports monolingual extraction (source terms ranked by casing,
position, and frequency) and bilingual extraction (source/target translation pairs from segments
with confirmed translations).
npm install -g typesterms
termextractor -xliff file.xlf
bilingualextractor -xliff file.xlf
A command-line tool that translates XLIFF 2.1/2.2 files using DeepL's machine translation service.
It sends the input XLIFF file to DeepL, waits for the translation to finish and writes the results back
to the specified XLIFF output file. Supports custom glossaries and configurable formality levels.
npm install -g xliff-deepl
xliff-deepl translate -i file.xlf -o translated.xlf
A command-line tool and library that translates XLIFF 2.x files using AI, sending a group of
segments per request instead of one at a time, carrying glossary terms, existing TM matches, and
a few segments of surrounding context so terminology and register stay consistent across a
batch. Supports seven engines behind one interface - ChatGPT, Claude, Gemini, Ollama, Mistral,
Qwen, and Z.ai. AI-proposed translations are never written into a segment's <target>;
each one is added as an <mtc:match> candidate for review, leaving the input
file untouched.
npm install -g xliffai
xliffai translate -i file.xlf -o translated.xlf -e chatgpt -k $OPENAI_API_KEY -m gpt-5