Certain XLIFF files can be imported via eclypse's import functionality. This article details how your file needs to be structured for eclypse to recognize it.


Eclypse recognizes Xliff files that are created by Unity's Localization Package. Start by selecting a Xliff file that has been exported from String Table Collections within Unity. Additional information on String Table Collections can be found on Unity's documentation reference


1. Drag and drop an Xliff file or browse files to locate one within import interface. 

2. If the file type is not recognized automatically, manually select the file type to be xliff.

3. If the language is not recognized automatically, manually select the language.

4. Click the "Configure" button to specify XLIFF version, plural handling and placeholder patterns encoded in your xliff files.

Eclypse supports both Xliff version 1.2 and 2.0. Depending on the Xliff standard, the data should be structured as follows. 

Version 1.2

<?xml version="1.0"?>
<xliff xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file original="path/to/table/localization_table_es.asset" source-language="en" target-language="es">
    <header>
      <skl>
        <external-file href="path/to/table/localization_es.asset" uid="cc5567aa-112f-4203-8c2f-ed77f938cf54" />
      </skl>
    </header>
    <body>
      <group id="6596a82a-0b91-4c9f-b63d-562a155cf624" resname="localization_table">
        <trans-unit id="11111111111" resname="age_question">
          <source>How old are you?</source>
          <target>¿Cuantos años tienes?</target>
        </trans-unit>
        <trans-unit id="222222222" resname="name_question">
          <source>what is your name?</source>
          <target>¿Cuál es su nombre?</target>
        </trans-unit>
        <trans-unit id="333333333" resname="address_question">
          <source>what is your address?</source>
          <target>¿Cuál es su dirección?</target>
        </trans-unit>
      </group>
    </body>
  </file>
</xliff>


Version 2.0

<?xml version="1.0"?>
<xliff xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" srcLang="en" trgLang="es" xmlns="urn:oasis:names:tc:xliff:document:2.0">
  <file id="cc5567aa-112f-4203-8c2f-ed77f938cf54" original="path/to/table/localization_es.asset">
    <group id="6596a82a-0b91-4c9f-b63d-562a155cf624" name="localization_table">
      <unit id="11111111111" name="age_question">
        <segment>
          <source>How old are you?</source>
          <target>¿Cuantos años tienes?</target>
        </segment>
      </unit>
      <unit id="222222222" name="name_question">
        <segment>
          <source>what is your name?</source>
          <target>¿Cuál es su nombre?</target>
        </segment>
      </unit>
      <unit id="333333333" name="address_question">
        <segment>
          <source>what is your address?</source>
          <target>¿Cuál es su dirección?</target>
        </segment>
      </unit>
    </group>
  </file>
</xliff>

If you are generating your Xliff files from Unity, you can simply follow the steps as outlined in Unity's localization knowledgebase.


Plural Handling

The Xliff file can contain plural keys. Eclypse recognizes two types of plural formatting for Xliff files.


1. ICU Style

Full specifications of ICU message formatting can be found here. However, eclypse supports a limited set of ICU capabilities. This is because only a portion of the ICU message formatting is applicable to the translation context. Your plurals can be encoded in a few different ways.


Supported Variation: 1

Generic
<source>{count, plural, one {Delete item} other {Delete items}}</source>

Supported Variation: 2

Generi
<source>{count, plural, one {Delete {count} item} other {Delete {count} items}}</source>

Supported Variation: 3

<source>Delete {count, plural, one {{count} item} other {{count} items}}</source>


Generic

Supported Variation: 4

<source>Delete {count, number} {count, plural, one {{count} item} other {{count} items}}</source>
Gen

2. JSON style

A Xliff file with JSON plurals looks like this:

<source>{"one": "Delete item", "other": "Delete %d items"}</source>
Generic

Placeholder Pattern

Placeholder pattern depends on which plural handling method you choose. If your Xliff file is encoded with ICU plurals, then you have to use the ICU Placeholder pattern. This is because, ICU Style format specifiers are tightly integrated with the ICU plural handling. On the other hand, if your file is using JSON style to encode the plurals, then you have 2 options for specifying the placeholder pattern.

Printf Style

Printf refers to a control parameter used by a class of functions in the input/output libraries of C and many other programming languages. In the simplest form, your placeholders should be encoded as shown below:

Hello %s! You have %d new messages.
Generic

Read the full list of recognized printf format specifiers here.


Eclypse Style

Eclypse employs a propriety pattern that is similar to printf. This pattern needs to be enclosed in square brackets and can contain a label. The label information is optional; however, if you are planning to export data from eclypse in ICU format, then using labels can make your output more readable. In the simplest form, your placeholders should be encoded as shown below:

Hello [%s]! You have [%d] new messages.
Generic

or optionally including labels:

Hello [%s:person_name]! You have [%d:number_of_messages] new messages.
Generic

Read the full list of recognized printf format specifiers here.