Preparing & Translating Supported File Types



Extension .xml
Smartling Identifier xml
Example File customxml.xml
Resources XML Standards 

Smartling supports XML 1.0 files by processing text within specified tags and attributes. You must specify the tags and attributes you want translated using the translate_paths directive.


Key and Variant metadata must be enabled and configured using the source_key_paths and variants_enabled directives.

Specifying Paths

Some directives require you to specify a path or set of paths to keys or strings in the file. A path is a slash-separated string which uses an Xpath-like syntax (although not all features of Xpath are supported). The node separator is always / (slash).

Wildcards are not allowed in path definitions.

To specify an attribute, use dot notation: node.attribute.

To specify paths based on an attribute value, use the syntax /node[@attribute="value"].

For the translate_paths directive, ending the path with a trailing / (slash) will also translate all child nodes.

For example, in the following file:


      <string name="home-button">Smartling Hotels</string>
   <string name="back-button">Back</string>
      <localize name="navigation">
        <string>Browse Hotels</string>
        <string>About Us</string>
        <string>Site Map</string>
      <localize name="description">
<string>An excellent budget hotel in New York City</string>
      <img src="/img/0156849.png" title="Bedroom - Basic Suite"/>
      <img src="/img/0156849.png" title="Bathroom - Basic Suite"/>

  • data/localize/string - will match “Browse Hotels”, “About Us”, “Site Map” and “An excellent budget hotel in New York City”.
  • data/images/img.title - will match “Bedroom - Basic Suite” and “Bathroom - Basic Suite”.
  • data/localize[@name="description"]/string - will match “An excellent budget hotel in New York City.”

HTML-like Files

Some XML files closely resemble HTML files and are more effectively translated by parsing them as HTML files. Smartling allows you to specify HTML as the file type when uploading an XML file in the dashboard to cope with this type of XML files. If uploading via API, give html as the Smartling identifier for the file.

Managing Untranslated Strings

If using File API to download Custom XML 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

Standard Placeholder Format

See Placeholders in Resource Files for more on placeholders.


File directives are supported, both inline and via our APIDirectives are specified in comments within the files, in the format listed below. The XML opening line <?xml version="1.0" encoding="utf-8"?> must precede the Smartling directives.

Inline File Format

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

API Parameter

smartling.[directive_name] = [value] 

Here are some examples of [directive_name], along with example values or paths.


Exact delivery depends on file type.

Values auto (default) | true | yes | false | no

Controls whether base characters ( > < & " ) are "escaped" into entities when delivering translations. This can be set universally for the whole file via API, or by setting the directive at the top/start of the file. The directive can also be placed inline to control the behavior of specific strings.

To use inline:
<!-- smartling.entity_escaping = false -->

<!-- smartling.entity_escaping = auto -->


For example, your translation might look like this:
This is an <hr> & " example string4

By default, using the "auto" setting, we will assume this is HTML from the <hr> tag.

When the translated file is downloaded, the translated string will be escaped as:
This is an <hr> &amp; &quot; example string4

Using <!-- smartling.entity_escaping = false --> will allow This is an <hr> & " example string4 to appear unescaped.


XML Characters (always escaped)

Character (name) Escape sequence

< (less-than)


> (greater-than)


& (ampersand)


' (apostrophe or single quote)


" (double-quote)




Exact delivery depends on file type.


html4 (default)|html5



By default, all html4 entities are unescaped, except the basic set: &lt; &gt; &amp; &quot;.

When this directive is set to html5, all html5 entities will be unescaped as well.


<!--smartling.entity_escaping_type = html5--> 



Values propagate | none

Used to retain entity escaping for all non-base entities. For example normally we turn &copy; into © but if we use this new directive the translation will automatically update to use escaping from the source. For each entity character we'll check to see if it was escaped in the source and try to match (propagate) it in the target.

The default is none which is the current behavior, which recognizes HTML4 entities only - if HTML5 entities are required as well, you must use the entity_escaping_type=propagate directive.

propagate will only affect non-base entities - all named entities except &amp; , &quot;, &lt;, &gt; . Base entities continue to be controlled by HTML detection and the entity_escaping directive.

If the same character is both escaped and unescaped in the same string propagate will return the characters in the translation escaped in the same order as they were in the source. However, if there are a different number of characters in the translation where the translation process removed or added some and the escaping is inconsistent among them, propagate will escape all entities for that character.

This directive can be placed inline, in the API or in a template (consult your SA about configuring directive templates).

This does not affect source content at all - so using it will not result in new strings.

Numerical entities are not considered at all with this directive, and are treated normally.


To use inline:
<!--smartling.entity_escaping_strategy = propagate-->


Values  true|TRUE|on|ON OR false|FALSE|off|OFF

When enabled, Smartling will make strings unique using variant metadata. Must be used in conjunction with the source_key_paths directive, which provides the information needed to generate variant metadata. 

If you have previously uploaded a file with variants turned off, and re-upload the file with variants on, Smartling will capture all content as new strings. You can configure SmartMatch to automatically match the existing translations.

Examples  <!-- smartling.variants_enabled = TRUE --> 



Values  A comma-separated list of paths to be captured as strings for translation. 
Description When included in this list, all plain text within the specified tag will be considered a translatable string. Optionally, you can append a “.” and a relevant attribute name to the path to translate tag attributes with the file. You can end the path with a trailing slash, “/” and it will treat all child nodes as translatable (content must still be text within a tag). 

<!-- smartling.translate_paths = data/localize/string, data/localize.title, data/localize/root/ --> 

Smartling will translate content in the data/localize/string & data/localize/root nodes. The title attribute of the data/localize node will also be translated.



Values  The value of this directive is expressed as [format]:[paths].

Specifies the format of strings for the specified paths and can enable HTML inside another file format. 

Current supported formats are:

  • HTML - string value will be parsed as HTML
  • @default - (note the leading at-sign) string value will be treated as simple text.
  • TXT - string value will be parsed as plain text with strings separated by new lines.
  • Markdown - string value will be parsed as Markdown.
  • block - passes all elements within the block as a single Smartling string.

Separate multiple paths by commas.

You may specify a single path for a format or a comma-separated list of paths enclosed in square brackets. The list may be empty.

Wildcards are allowed in path definitions.

  • If no wildcards are used, then the path identifies a single node and all its children ("exact subpath").
  • If wildcards are used, then a path identifies a set of nodes and all their children ("path pattern"). Currently, only * (asterisk) wildcard is implemented, which means "one or more nodes with any names".
  • Exact subpaths have precedence over path patterns.

See Content Parsing for more information.


<!-- smartling.string_format_paths = -->

Disables the effect of the previous string_format_paths instruction.

<!-- smartling.string_format_paths = html: /product/description -->

Enables HTML in /product/description only.

<!-- smartling.string_format_paths = html: /product/description/ -->

Enables HTML in /product/description and all its child nodes.

<!-- smartling.string_format_paths = html: /product/description/, html: /product/title -->

Enables HTML in /product/description and all its child nodes, and the product/title node.

<!-- smartling.string_format_paths = block: /product/description -->

Enables block and everything inside of root to be one string.



Values 1) Custom Perl compatible regular expression.
2) 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.

<!-- smartling.placeholder_format_custom = \[.+?\] -->

Any characters surrounded by square brackets will be treated as a placeholder.



Description  Used to specify a standard placeholder format. 

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

Specifies iOS-style placeholders for the file.



Values  translate OR notranslate 
Description  Use this directive to enable or disable processing of translation strings in the file. You must turn translation back on after the strings you want to exclude.

<!-- smartling.sltrans = notranslate -->

Strings after this directive will be captured as strings but excluded from translation. (It is the entire string that is excluded, not just a portion of the string.)

<!-- smartling.sltrans = translate -->

Strings after this directive will be translated.




A comma separated list of paths, as used to create “keys” for strings on translate_paths.

The key will be a ':#:'-separated string of all the keys leading to the source string. For example: “string”, “group1:#:string”.

Specify the full path to the value, then indicate which part of the path should be used as the key using {} notation.  Each part of the path that has {} will be used to construct the key, with each part separated by a ':#:' in the key.

You can use the value of an attribute in the path by using the '.' notation to indicate the attribute you want to capture as part of the key.


Used to define the schema for capturing a key for each source string.

Keys are required:

If you want to import pre-existing translations from a file with the same structure
If you want to create variants of strings that would otherwise be duplicates; by default, Smartling does not create duplicate strings.
Creating or updating variants for previously uploaded strings will create new strings that will not have translations. The SmartMatch feature can be configured to automatically apply the existing translations, or translators can use the 100% match from the Translation Memory to manually apply the translation.

Note: Keys are not created if the element is a sibling of the element that has the string, e.g.:

string_format_paths = /data/value
source_key_paths = /data/


Result: though there are no errors, no key is created.


<!-- smartling.source_key_paths = data/item/{}/value -->

Smartling will capture the value of the id attribute of the data/item/content/ node as part of the key.

<!-- smartling.source_key_paths = data/item/{key_name} -->
Smartling will capture node name key_name as the key.

<!-- smartling.source_key_paths = {data}/{item}/{key_name} -->
Smartling will capture the entire path as the key.


Values Integer - Accepted values are 0 - 100
Description Sets the percentage by which original strings are inflated when downloading pseudo translations. If this directive is not set, pseudo translations are 30 percent longer than the original strings.

<!-- smartling.pseudo_inflation = 80 -->

Downloaded pseudo translations will increase the length of original strings by 80 percent.



Values  Instruction text
Description Instructions from XML file. Order is important. The element with the instruction must be a sibling of the corresponding element with the translation (as specified by translate_paths), and it must appear before the translation in the file. 

<!-- smartling.instruction_paths = data/unit/instruction --> 

(See code sample below.)

instruction_paths code example:

      <instruction>instruction text</instruction>
      <string>translation text</string>


Values  Integer - Values such as 10, 20, etc.

Source string level instructions for character length. character_limit_paths point to elements that define character limits.

Order is important. The element with the limit must be a sibling of the corresponding element with the translation (as specified by translate_paths), and it must appear before the translation in the file.


<!-- smartling.character_limit_paths = data/unit/limit, data/sub-level/unit/limit, data/item/limit -->

(See code sample below)

character_limit_paths code example:

      <string id="id1">data 0</string>
      <string id="id2">data 1</string>
   <string id="id3">data 2</string>
   <string id="id4">data 3</string>
   <string id="id5">data 4</string>
   <string id="id6">data 5</string>
   <string id="id7">data 6</string>
   <string id="id8">data 7</string>
   <string id="id9">data 8</string>
   <string id="id10">data 9</string>
   <text name="name1">data 10</text>


Values  Tags such as: <ol>, <li>, <strong>, <icon>

This directive allows for specified tags to be treated as inline tags (visible and moveable for translators and editors) versus block-level tags (creates a new string and are not visible).

NOTE: This only works for nested HTML parsing in XML, which must be in entity escaped form.

<!-- smartling.translate_paths = root/text -->
<!-- smartling.string_format_paths = html: /root/text -->
<!-- smartling.force_inline_for_tags = fine -->
I have some <fine>text</fine> that is in three pieces.
I have some other &lt;fine&gt;text&lt;/fine&gt; that is not.



Values  all|trim
Description This directive affects XML download only - where all is the default and the current bahavior.

<!-- smartling.cdata_whitespace_strategy = trim -->

Reduces whitespace




on|yes|true or off|no|false or leading|trailing

The default value is on


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 trim whitespaces, as it enables or disables whitespace trim management for the ingested strings.

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.


<!-- 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


Was this article helpful?