xlf-extract
Extracts source messages from XLIFF (.xlf) files into a translation bundle. This is a simple YAML file that can be copied and translated for different locales.
The translated messages can be populated back into the XLIFF files using xlf-translate.
These tools are intended to simplify the localization of Angular 2 i18n - enabled apps.
In Angular 2 each change in the application may alter the unit IDs in the message file. Normally, you'd have to track each unit and update its translation.
With this set of tools the correct translations can be filled-in automatically from the YAML message bundles based on your unique keys.
See the sample i18n Angular app for more details.
Installation
npm install -g xlf-extract
Usage
xlf-extract messages.xlf --lang-file=lang/en.yml
This will extract all source elements from the messages.xlf
file into the language file.
Optionally, specify --use-target
to extract the target
(translated) messages:
xlf-extract --use-target messages.xlf --lang-file=lang/en.yml
Description
Normally, you'd localize an attribute using the following syntax:
Hello!
This utility makes use of the optional meaning tag to associate the message with an unique key.
Hello!
The key will be persisted in the messages file as a "meaning":
Hello! A hello world message for the localized component localized.component.hello
This utility will extract the source messages along with descriptions into a message bundle. This file is then copied and translated for different locales.
The message bundle is an YAML file that lists all messages as a tree. For example, the localized.component.hello
key and its translation are represented as:
localized: component: # A hello world message for the localized component hello: Bonjour!
To populate the message file with the translations from the message bundle, use the xlf-translate companion tool.