Creating Unique String Variants in the GDN
By default, the Smartling Global Delivery Network (GDN) captures only the text of a string, including markup, to create each unique string. This means that repetitions of identical strings are not considered unique, which is help you save money when translating your website.
For example, if you have the menu item "Contact" in the top navigation of your site, you only need to capture and translate this string one time in Smartling though it appears across many pages.
In some cases, you may need to translate repetitions of an identical string differently in certain elements on your site. This article covers methods you can use to identify variants on your website that will create unique strings for translation within a specific elements or page.
For example, you may want to translate the word "Watch" that appears on a button to watch a video on your website differently than the word "Watch" on a product detail page for a wrist watch.
Looking to create variants in a file-based project? See our API documentation.
Adding variants by HTML attribute
Variants can be assigned to strings within a certain HTML element by adding the data-sl-variant attribute to the element. The value within the attribute will be used as the variant metadata for all of the strings within that element, creating a unique strings. Here is an example:
class="butn orange" data-sl-variant="somevariantname"
Adding variants to HTML attribute values
Variants can also be added to attribute values within a tag, like meta-tag values. This can be useful for creating unique strings for SEO purposes. Using the data-sl-attr-variant attribute, you can specify attribute names and the corresponding variant names to use in a comma-separated list:
Creating variants based on URL
The Smartling GDN can assign variants to strings based on some or all of the page URL where a string appears. This is an advanced GDN configuration which can be enabled using the rps_variant_from_page_uri rule. The parameters of this rule include a regex pattern to determine which pages to assign a variant and what part of the URL to use as the variant value.
To learn more about advanced integration tools, see our Advanced Integration section.
Assigning variants to JSON keys
For JSON content being translated via the Global Delivery Network, variants can be assigned to specific JSON keys using the sl_variant directive. Similar to the sl_translate directive, which should be used in conjunction, the sl_variant key is added to the beginning of a JSON object and the value should include a comma-separated list of key names and corresponding variant values: