0.2.2 • Published 5 years ago

xlf-extract v0.2.2

Weekly downloads
18
License
BSD-3-Clause
Repository
github
Last release
5 years ago

Build Status npm version

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:

<span i18n="A hello world message for the localized component">Hello!</span>

This utility makes use of the optional meaning tag to associate the message with an unique key.

<span i18n="localized.component.hello|A hello world message for the localized component">Hello!</span>

The key will be persisted in the messages file as a "meaning":

<trans-unit id="cb5fabf68b14f52c0d7cbc2b90393f8897310ba7" datatype="html">
  <source>Hello!</source>
  <target/>
  <note priority="1" from="description">A hello world message for the localized component</note>
  <note priority="1" from="meaning">localized.component.hello</note>
</trans-unit>

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.

See Also

0.2.2

5 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.0

7 years ago