Preparing Content for Translation

XML

 

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

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

Keys-Variants

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:

XML

<data>
      <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>
      <localize name="description">
<string>An excellent budget hotel in New York City</string>
      </localize>
   <images>
      <img src="/img/0156849.png" title="Bedroom - Basic Suite"/>
      <img src="/img/0156849.png" title="Bathroom - Basic Suite"/>
   </images>
</data>

  • 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 (includeOriginalStrings=true) Smartling returns the original string.

Standard Placeholder Format

See Placeholders in Resource Files for more on placeholders.

Directives

Format

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

 

entity_escaping

Exact delivery depends on file type.

Values auto (default)
true (or yes)
false (or no)
Description Can control whether or not characters will be "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.
Examples  

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

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

For example, your translation might look like this:
Smartling HTML escaping < > & " example string4

By default, using the "auto" setting, we would assume this is HTML from the <hr> tag and it would be converted to:
Smartling HTML escaping &lt; &gt; &amp; &quot; example string4

Using smartling.entity_escaping = false would allow Smartling HTML escaping < > & " example string4 to appear as it should.

variants_enabled

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

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

 

translate_paths

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). 
Examples 

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

 

string_format_paths

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

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

Currently 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.
block - passes all elements within the block as a single Smartling string.
Separate multiple formats 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.

Examples

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

 

placeholder_format_custom

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.
Examples 

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

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

 

placeholder_format

Values  NONE; C; IOS; PYTHON; JAVA; YAML; QT, RESX 
Description  Used to specify a standard placeholder format. 
Examples 

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

Specifies iOS-style placeholders for the file.

 

sltrans

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.
Examples 

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

 

source_key_paths

Values 

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

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

Description

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 cause new strings to be created 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 to manually apply the translation.

Specify the full path to the value, then indicate which part of the path should be used as the key using {} notation.

Examples 

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

Smartling will capture the name atribute of the data/item/string node as the key.

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

Smartling will capture the content of the string_name node as the key.

 

pseudo_inflation

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.
Examples 

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

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

 

instruction_paths

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. 
Examples 

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

(See code sample below.)

instruction_paths code example:

<data>
   <unit>
      <instruction>instruction text</instruction>
      <string>translation text</string>
   </unit>
</data>

character_limit_paths

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

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.

Examples 

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

(See code sample below)

character_limit_paths code example:

<data>
   <unit>
      <string id="id1">data 0</string>
   </unit>
   <unit>
      <limit>10</limit>
      <string id="id2">data 1</string>
   </unit>
   <sub-level>
   <unit>
   <limit>20</limit>
   <string id="id3">data 2</string>
   </unit>
   </sub-level>
   <unit>
   <limit>30</limit>
   <string id="id4">data 3</string>
   <string id="id5">data 4</string>
   </unit>
   <unit>
   <limit>40</limit>
   <string id="id6">data 5</string>
   <limit>50</limit>
   <string id="id7">data 6</string>
   </unit>
   <unit>
   <limit>60</limit>
   <string id="id8">data 7</string>
   <limit>NONE</limit>
   <string id="id9">data 8</string>
   <string id="id10">data 9</string>
   </unit>
   <item>
   <limit>100</limit>
   <text name="name1">data 10</text>
   </item>
</data>

smartling.force_inline_for_tags

Values  Tags such as: <ol>, <li>, <strong>, <icon>
Description 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).
Examples 

<!-- smartling.force_inline_for_tags = icon, tooltip -->

Was this article helpful?