XLIFF format: 1.2 vs 2.0, plurals and AI translation of .xlf files
XLIFF 1.2 and 2.0 bilingual files with source, target and notes.
.xlf.xliffformat: xliffevery locale in one file
What it is
XLIFF is the interchange format of the localization industry and Angular's i18n output. Each file pairs a source language with one target.
Example
src/locale/messages.xlf
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file source-language="en" target-language="es" datatype="plaintext" original="ng2.template"> <body> <trans-unit id="checkout.pay" datatype="html"> <source>Pay <x id="INTERPOLATION" equiv-text="{{ total }}"/></source> <target>Pagar <x id="INTERPOLATION" equiv-text="{{ total }}"/></target> <note priority="1" from="description">Primary button on checkout</note> </trans-unit> </body> </file></xliff>How Glossa handles it
- Plurals
- XLIFF has no plural structure of its own; ICU plural messages inside a unit are translated as one message with their structure kept.
- Comments and context
- <note> elements become context.
- Placeholders
- Inline elements (<x/>, <ph/>, <pc>) are treated as placeholders and must appear in every target.
- Round trip
- Both 1.2 and 2.0 are detected automatically. The unit key is resname when present, otherwise id; inline markup is kept as written.
Translate it from the command line
Push the source-language file; strings are deduplicated against the rest of your workspace and queued for translation. Pull writes src/locale/messages.xlf back in the same format.
npx @meterapp/glossa loginnpx @meterapp/glossa push src/locale/messages.xlf --project appnpx @meterapp/glossa pull --project app --locale es,de,jaOr ask an agent over MCP: “Push src/locale/messages.xlf to Glossa and pull Spanish.” It calls push_file and pull_file. See the CLI and MCP guides.
Questions
- What is an XLIFF file?
- XLIFF (XML Localization Interchange File Format) is an OASIS standard for passing translatable text between tools. An .xlf file is plain XML that pairs each source string with its translation for one source and one target language, with notes for translators and inline codes standing in for markup and placeholders. Angular's ng extract-i18n writes it (messages.xlf), Xcode exports it inside .xcloc catalogs, and any text or XML editor opens it.
- What is the difference between XLIFF 1.2 and 2.0?
- XLIFF 1.2 (2008) declares source-language and target-language on each <file> and puts every string in a <trans-unit> with <source>, <target> and <note>. XLIFF 2.0 (2014) moves the languages to srcLang and trgLang on the root, splits each <unit> into <segment>s, groups notes in <notes>, replaces the inline elements with <ph/>, <pc>, <sc/> and <ec/>, and is not backward compatible. Glossa reads both and writes each file back in the version it read.
- How do plurals work in XLIFF?
- XLIFF has no plural element. Angular writes an ICU message inside one unit ({VAR_PLURAL, plural, =0 {just now} other {…}}), and a plural inside a longer message becomes its own unit, referenced by <x id="ICU"/>. Glossa translates each unit as one string, so the ICU branches stay together, and inline elements such as <x/> must appear in the translation as often as in the source or the draft goes to review.
- Do I need XLIFF to translate an iOS app?
- No. Xcode's Export Localizations wraps an XLIFF file in an .xcloc catalog for translators to send back. Glossa reads String Catalogs (.xcstrings), .strings and .stringsdict files directly, so you push the catalog and pull the translations into it without exporting or importing XLIFF.
Other formats
Xcode String CatalogFlutter ARBJSON (key/value, i18next)YAML (Rails i18n)Apple .stringsApple .stringsdictAndroid strings.xmlGettext PO/POTJava .properties.NET RESXCSV / TSV (multi-locale)Plain text (whole file)
Moving from Crowdin? Read the comparison.