xliff-merger is a tool that takes a generated xliff file (base.xlf) and merges it with an existing and already translated xliff file (other.xlf).
It reads every <trans-unit>
tag found in the base.xlf file and looks for new translations in the other.xlf file. A translation is found as a <target>
tag, this tag is then copied as a child node of the <trans-unit>
tag. In the end, the result will be saved in a file called merged.xlf
, all tags will be indented and sorted by the id attribute.
xliff-merger uses xslt4node, a XSLT package wrapping the XSLT interface of the Java API for XML Processing (JAXP).
- node-gyp
- Java 6+
- JNI capabilities must be enabled when running java on a Mac OSX:
/Library/Java/JavaVirtualMachines/<version>.jdk/Contents/Info.plist
<key>JVMCapabilities</key> <array> ... <string>JNI</string> ... </array>
- JNI capabilities must be enabled when running java on a Mac OSX:
Run npm install
xliff-merger will merge the following files:
base.xlf
is the translation file generated by angular, usually by doing:ng xi18n --i18n-format xlf
other.xlf
is the file with the translations, this is the one that your translation team will send you back.
Merge the files by running node xliff-merger.js
, the merge will be saved in a file called merged.xlf
.
- Compile and share this tool to be added to angular projects as a node script.
- Test it using yarn instead of npm
- Find a way to publish this tool to avoid the pre-requisites, see here.