Skip to main content

XLIFF 2.0

Extension

.xml, .xlf, .xliff

Smartling Identifier

xliff2

Example File

Resources

Example File

<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0"
       xmlns:xmrk="urn:xmarker"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:oasis:names:tc:xliff:document:2.0 xliff_core_2.0.xsd"
       version="2.0"
       srcLang="en-US"
       trgLang="uk-UA">
  <file id="description.properties">
    <unit id="1">
      <segment>
        <source>Various types of model.</source>
        <target></target>
      </segment>
    </unit>
    <unit id="2">
      <segment>
        <source>Machine Learning has drawn a lot of attention.</source>
      </segment>
      <ignorable>
        <source> </source>
      </ignorable>
      <segment>
        <source>Then we introduce the needed mathematical notation.</source>
      </segment>
    </unit>
  </file>
</xliff>

Smartling supports .xlf, .xliff, and .xml files that use the XML Localization Interchange File Format v 2.0 (XLIFF2).

Articulate XLIFF 2.0 is not supported, meaning you cannot upload a translation XLIFF 2.0 file to Articulate Storyline. You must translate XLIFF 1.2 and choose the articulate option for translations to be compatible with Articulate import.

Visual Context

Visual context is not automatically provided for XLIFF files. To provide visual context for your XLIFF file, you can upload a context file manually, or integrate with Smartling’s JavaScript Library, or the Context Capture Google Chrome Extension, or an API.

An alternative method of providing visual context is to allow translators to view the raw XLIFF file as context. Large files can split into chunks of strings or kilobytes by your Smartling Representative.

To enable raw file image context for a project:

  • Go to Settings > Contexts

  • Under Use file content as visual context, switch XLIFF on

String Instructions

Smartling automatically captures XLIFF notes and makes them translator instructions. See xliff_note_to_instruction for more information.

Excluding Strings

To exclude content from translation, you can use XLIFF’s translate attribute. To exclude a string from translation, set translate=no. See XLIFF Resource Documentation for details on the translate attribute.

Plurals in XLIFF 2.0 Files

XLIFF 2.0 does not support plural translation.

Standard Placeholder Format

See Placeholders in Resource Files for more on placeholders.

XML Characters

The following XML character are always escaped. You can control this by using the entity_escaping directive.

Character (character name)

Escape sequence

< (less-than)

&lt;

> (greater-than)

&gt;

& (ampersand)

&amp;

' (apostrophe or single quote)

&apos;

" (double-quote)

&quot;

Return Untranslated Strings as Empty

If using File API to download Custom XLIFF files from Smartling, the parameter includeOriginalStrings=false can be set to return an empty string if no translation is available. By default, Smartling returns the original source string if no translation is available, meaning the parameter is set to includeOriginalStrings=true

Directives

File directives are supported via API, and some are also supported inline. Inline file directives are specified as comments directly within the source file, while API file directives are added as parameters when uploading a source file via API.

Inline File Format

<!-- smartling.[directive_name] = [value] -->

API Parameter

smartling.[directive_name] = [value]

Here are examples of supported directives for XLIFF 2:

Control String Length

Directive

xliff_segment_code_strategy

Yes

Values

  • string

  • span

Description

Controls how long strings should be parsed; either as a separate string or as one long string.

string - every segment is ingested as a separate original string.
​span - all segments are ingested as part of one string. Each segment is encoded with <span> with attribute t="seg", so they can be reordered in a translation.

Example

<!-- smartling.segment_code_strategy=span -->

Smartling will parse a long string into one long string.

Change String Parsing

Directive

string_format_paths

Values

Syntax
​smartling.string_format_paths=<JSON_CONFIGURATION>

The directive value must be a JSON object where:

  • Keys are format types (case-insensitive):

    • HTML - Parse content as HTML

    • TXT (or plain_text) - Parse content as plain text with strings separated by new lines

    • Markdown (or md) - Parse content as Markdown

  • Values are XPath selectors that match specific units

Basic Example

smartling.string_format_paths={"html": "//unit[@type='x-contentful-field-type:RichText']", "txt": "//unit[@type='x-contentful-field-type:Text']"}

This example says:

  • Parse units with type="x-contentful-field-type:RichText" as HTML

  • Parse units with type="x-contentful-field-type:Text" as plain text

XPath Selector Syntax

The directive uses XPath expressions to match units. Currently, only //unit selectors are supported (you cannot use other XLIFF tags like //group).

Description

The smartling.string_format_paths directive allows you to specify different string parsing formats (HTML, TXT, or Markdown) for different units in your XLIFF 2.0 file based on their attributes.

This is particularly useful when working with content management systems like Contentful that mix different content types in a single XLIFF file.

Important Notes

  • Order Matters: When multiple rules match the same unit, the first matching rule wins so it is important to define more specific rules before general ones.

  • JSON Escaping: When using the directive in curl commands or API calls, you must properly escape quotes. Example:
    ​curl --form 'smartling.string_format_paths="{\"html\": \"//unit[@type='\'x-contentful-field-type:RichText\'\']\", \"txt\": \"//unit[@type='\'x-contentful-field-type:Text\'\']\"}"'

  • XPath Version: This directive is implemented with XPath 1.0. XPath 2.0 functions like ends-with(), matches(), lower-case(), and upper-case() are not supported.

  • Tag Limitation: Only //unit tags are supported in selectors. You cannot use other XLIFF 2.0 tags like //group.

  • Replace Global Directive: The string_format_paths directive provides per-unit format selection and should be used instead of the global smartling.string_format directive. The global directive (supported only via API or directive template) applies a single format to an entire file, meaning all units are parsed using the same format.

Examples

Basic Attribute Matching:
​smartling.string_format_paths={"html": "//unit[@id='123']"}

Multiple Conditions with Logical Operators:
​smartling.string_format_paths={"html": "//unit[@type='RichText' or @type='HTML']"}

smartling.string_format_paths={"txt": "//unit[@id='content' and not(@type='skip')]"}

Attribute Presence Check:
​smartling.string_format_paths={"html": "//unit[@translate]"}

Reference <originalData> Elements

Directive

original_data_type

Yes

Values

Currently, supported formats are:

  • html - <originalData> elements will be referenced and parsed as HTML.

  • none - <originalData> elements will not be referenced.

Description

Allows for <originalData> XLIFF elements to be referenced.
​
When this directive is set to "html" and the directive "string_format" is also set to "html", <originalData> XLIFF elements will be referenced to enable block and inline tag parsing, similar to raw HTML parsing.

Example

<!-- smartling.original_data_type = html-->

Smartling references <originalData> elements and parses them as HTML. Please note that in this example, the directive "string_format" should also be set to "html".

Translator Instructions

Directive

xliff_notes_to_instruction

Values

  • file

  • group

  • unit (default)

  • none

Description

Controls where translator instructions are located in the file.

By default, all notes inside a unit are ingested as translation instructions.

none - disables the ingestion of translator instructions.

Example

<!-- smartling.xliff_notes_to_instruction=group, unit -->

The translator instructions will consist of group-level notes and unit-level notes.

Standard Placeholder Format

Directive

placeholder_format

Yes

Values

  • NONE

  • C

  • IOS

  • PYTHON

  • JAVA

  • YAML

  • QT

  • RESX

Description

Used to specify a standard placeholder format.

Example

<!-- smartling.placeholder_format = IOS -->

Specifies iOS-style placeholders for the file.

Custom Placeholder Format

Directive

placeholder_format_custom

Yes

Values

  • Custom (Java Regex)

  • NONE - disables any current custom placeholders.

Description

Specifies a custom placeholder format. Any text in your file matching the regular expression you provide will be captured as a placeholder.

See Placeholders in Resource Files for more on placeholders.

Example

<!-- smartling.placeholder_format_custom=\{([^}]+)\} -->

Any characters surrounded by curly brackets, e.g., {first name}, will be treated as a placeholder.

See Placeholders in Resource Files for more on placeholders.

Trim Whitespace

Directive

whitespace_trim

Yes

Values

on|yes|true OR off|no|false OR leading|trailing
​
The default value in on.

Description

A whitespace is any character or series of characters that represent horizontal or vertical space in typography. When rendered, a whitespace character is not a visible mark, but does occupy an area or space on a page.

Although whitespaces are necessary within a string (typically to separate words), unnecessary whitespaces can be found at the start of a string (leading) and at the end of a string (trailing).

With this directive, you can manage whitespace trimming.

By default, the leading and trailing whitespaces are trimmed.

You can choose to disable trimming or specify trimming for leading or trailing whitespaces.

The directive can be used inline or as the API request parameter.

Example

<!-- smartling.whitespace_trim=on-->
Smartling will trim leading and trailing whitespaces (default)

<!-- smartling.whitespace_trim=off -->
Smartling will not trim leading or trailing whitespaces

<!-- smartling.whitespace_trim=leading -->
Smartling will trim only leading whitespaces

<!-- smartling.whitespace_trim=trailing -->
Smartling will trim only trailing whitespaces

Did this answer your question?