XLIFF to JSON Converter
Convert TYPO3 Flow XLIFF (.xlf) translation files to JSON format compatible with angular-translate. Supports XLIFF 1.2 with namespace handling.
Converted JSON will appear here...
About
XLIFF (XML Localisation Interchange File Format) is the OASIS standard for exchanging localization data between tools. TYPO3 Flow stores translations as XLIFF 1.2 files under Resources/Private/Translations/, namespaced with urn:oasis:names:tc:xliff:document:1.2. When building Angular frontends with Pascal Precht's angular-translate, these XML files must be converted to flat JSON key-value maps. Manual conversion is error-prone: missed trans-unit elements, broken namespace resolution, or malformed keys from resname attributes silently corrupt your i18n pipeline. This tool parses XLIFF 1.2 documents using the native DOMParser, extracts translation units with proper namespace handling, and outputs JSON structures directly consumable by $translateProvider.useStaticFilesLoader(). It handles both source-only and source-target extraction modes. Note: this tool assumes well-formed XLIFF 1.2. XLIFF 2.0 uses a different schema and is not supported.
Formulas
The conversion follows a deterministic extraction pipeline from XML DOM to JSON object:
For each <trans-unit> element, the JSON key is resolved as:
When nested output is selected, dot-separated keys are split into object hierarchies:
The value extraction depends on mode:
Where resname is the preferred key attribute from <trans-unit>, id is the fallback identifier, source is the source language element content, and target is the target language element content. Total units extracted: N = count(trans-unit) across all <file> elements in the document.
Reference Data
| XLIFF Element | Attribute | JSON Mapping | Description |
|---|---|---|---|
| <file> | source-language | Top-level locale key | ISO 639-1 language code of source |
| <file> | target-language | Top-level locale key | ISO 639-1 language code of target |
| <file> | original | Metadata (ignored in output) | Original file reference path |
| <trans-unit> | id | JSON key (fallback) | Unique identifier for translation unit |
| <trans-unit> | resname | JSON key (preferred) | Resource name, often dot-notated |
| <source> | - | JSON value (source mode) | Source language text content |
| <target> | - | JSON value (target mode) | Target language text content |
| <note> | - | Ignored | Translator comments, not exported |
| <group> | restype | Key prefix (if nested) | Logical grouping of translation units |
| <body> | - | Container | Wraps all trans-unit elements |
| <header> | - | Ignored | File-level metadata, skeletons |
| Namespace | urn:oasis:names:tc:xliff:document:1.2 | - | XLIFF 1.2 XML namespace URI |
| TYPO3 Convention | id format | Dot-separated key | e.g. controller.action.label |
| angular-translate | JSON format | Flat key-value | {"KEY": "value"} |
| angular-translate | Nested format | Nested object | {"KEY": {"SUB": "value"}} |
| File extension | .xlf | .json | Standard file extensions |
| Encoding | UTF-8 | UTF-8 | Both formats use UTF-8 |