Preparing Content for Translation

How Smartling Creates Variants

Smartling creates variants when two strings have the same text, but different context or metadata. Applying variants to identical strings will create unique strings, even if string sharing is enabled.

Context is captured differently depending on the project type.

Global Delivery Network Projects

The Global Delivery Network analyzes every HTML request and captures strings based on HTML block tags. If content within the block tags (such as an in-line tag) changes, Smartling creates a new unique string, even if the text itself is identical to another unique string.

Example 1:

HTML

String 1: p>Please contact us to find out more.</p>
String 2: <p>Please <a href="contact.html">contact us</a> to find out more.</p>

These are parsed by the GDN as two unique strings, even though the text is identical because there are different inline tags within the blocks.

To manually create variants, you can use a variant HTML attribute within a block tag to enclose the string you want to make a variant and assign it a numeric or text value. The HTML5 compliant version of this attribute is data-sl-variant.

Example 2:

HTML

String 1: <div>Same text, captured twice with variant metadata.</div>
String 2: <div variant="Variant1">Same text, captured twice with variant metadata.</div>
String 2 (HTML5): <div data-sl-variant="Variant1">Same text, captured twice with variant metadata.</div>

Smartling parses these as two unique strings, even though the content within the block tags is identical. String 1 has no variant metadata, String 2 has the variant metadata Variant1.

Application Resource File Projects

How Smartling creates variants from Application Resource Files depends on the file type and the parsing instructions included in the file. Most application resource files use key/value pairs, where the ‘value’ is the string and the ‘key’ is a label. For some file types, Smartling may capture keys as metadata for a string and create Variants if two different keys have the same value. See below for detailed information on each file type:

Key-value based files: Java Properties, iOS/Mac OS .strings

Every string is created with variant metadata, which is the key. If the ‘keys’ are different for two strings with the same ‘value’ then Smartling will create two strings using the key as context metadata.

Java

string1= Home
string2= Home

YAML

Every string is created with variant metadata. The variant metadata is the full path of keys leading to the translatable string.

YAML

Strings:
string1: Home
string2: Home

Android Resources

Every string is created with variant metadata which is the value of the string.name attribute. So if the value of a string is the same for two strings but the string.name attribute is different Smartling creates two strings.

XML

<string name="string1">Home</string>
<string name="string2">Home</string>

RESX-RESW

Every string is created with variant metadata which is the value of the data.name attribute. If the value of a string is the same for two strings but the data.name attribute is different, Smartling creates two strings.

XML

<data name="string1">
&nbsp;<value>Home</value>
</data>

<data name="string2">
&nbsp;<value>Home</value>
</data>

Gettext POT

The msgid value is captured as the key but is not used to create variants.

The string is captured with variant metadata if msgctxt is present for the string. The value of the msgctxt key will be used as variant metadata.


#:0001
msgctxt "string1"
msgid "Home"
msgstr ""

#0002
msgctxt "string2"
msgid "Home"
msgstr ""

JSON

Strings are created with variant metadata only if you have configured the JSON file to use keys and have turned on the variants behavior. Then the Smartling key for a string is used as the variant metadata for that string. For accounts created after June 11th 2015, JSON strings are created with variant metadata by default, with the full path of keys leading to a string being captured as the variant.

For some files uploaded before June 2015, an older parser version applies and variants must be enabled through file directives.

JSON

{
"string1": "Home",
"string2": "Home"
}

XML

Strings are created with variant metadata only if you have configured the XML file to use keys and have turned on the variants behavior. Then the Smartling key for a string is used as the variant metadata for that string.

XML

<?xml version="1.0" encoding="utf-8"?>
<!-- smartling.translate_paths = data/item/string -->
<!-- smartling.source_key_paths = data/item/{string.name} -->
<!-- smartling.variants_enabled = true -->
<data>
&nbsp; <item>
&nbsp; &nbsp; <string name="name1">Home</string> &nbsp; </item>
&nbsp; <item>
&nbsp; &nbsp; <string name="name2">Home</string>
&nbsp; </item>
</data>

Business Documents Projects

All strings are ingested uniquely by document.

Adding Variant Metadata After Translation has Begun

Please note, if you capture content without variant metadata, begin translation and, later, add variant metadata (for example: by adding variant tags to your HTML or re-uploading a file with variants enabled), all strings with variant metadata will be considered new and unique. Configuring SmartMatch can help you avoid having to retranslate these strings, but they will be counted as new strings and add to your accounts Words Under Management.

 

Was this article helpful?