XLIFF

XLIFF (XML Localisation Interchange File Format) is an XML-based standard designed to facilitate the exchange of localization data between different tools and services.

Many development environments, such as Xcode, support XLIFF as an alternative to proprietary resource formats.

Format

  • LingoHub supports files based on the XLIFF 1.2 standard.
  • XLIFF files can store both source and target language information in a single file.
  • The <file> element must define the source-language and target-language attributes.
  • While the <target> element is optional, the <source> element is mandatory.
  • LingoHub uses the id attribute of the <trans-unit> element (or the resname attribute) as the segment key.
  • <trans-unit> elements can be organized into <group> elements. If grouping is used, the group id prefixes the segment key.
  • The <note> element within a <trans-unit> is imported as a segment description.
  • LingoHub preserves and exports all element attributes, <context-group> information, and <header> metadata as they were imported.
  • Placeholders are defined using the <ph> element (e.g., <ph id="1">{0,number}</ph>).

LingoHints can be included in a <note> element:

<trans-unit id="2" resname="key_2">
  <source xml:lang="en">Box &quot;<ph id="1">{0}</ph>&quot; is blue.</source>
  <target xml:lang="de">Box <ph id="1">{0,number}</ph> ist blau.</target>
  <note><lh>{"status": "DRAFT","qc": {"min": "3","max": "20"},"labels": ["q3-2024"],"not_translatable": false}</lh></note>
</trans-unit>

Example

Additional example files are available on GitHub.

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" 
  xmlns="urn:oasis:names:tc:xliff:document:1.2" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd">
<file original="sample.properties" 
  source-language="en" target-language="de" 
  datatype="javapropertyresourcebundle">
<body>
   <trans-unit id="1" resname="key_1">
      <source xml:lang="en">Box 12 is <ph id="1">{0,number}</ph> inches high.</source>
      <target xml:lang="de">Box Zwölf ist <ph id="1">{0,number}</ph> Zoll hoch.</target>
   </trans-unit>
   <trans-unit id="2" resname="key_2">
      <source xml:lang="en">Box &quot;<ph id="1">{0}</ph>&quot; is blue.</source>
      <target xml:lang="de">Box <ph id="1">{0,number}</ph> ist blau.</target>
   </trans-unit>
    <group id="messages">
      <trans-unit id="3" resname="key_3" xml:space="preserve">
          <source>Hello <ph id="1">username</ph></source>
          <context-group name="sample_properties" purpose="location">
            <context context-type="sourcefile">XliffInfo.java</context>
            <context context-type="linenumber">34</context>
          </context-group>
      </trans-unit>
    </group>  
</body>
</file>
</xliff>

References