We've launched a new support center at help.smartling.com. This site will continue to be maintained into January 2017. Please update your bookmarks.
Follow

How to Pattern Match Variable Content

The following article applies to Global Delivery Network project types. 

Smartling uses patterns to avoid retranslating repeating content with variables. Patterns can be created in the Dashboard, or can be created by integrating your website's HTML code using the Smartling notranslate class.

How to Pattern Match Inline Content

Using the “notranslate” tag within an inline tag such as a <span> or <strong>, you can use a placeholder that matches the overall pattern to force the content to be extracted for translation; for example, the following content

    <div>

          Hello, <span class=”notranslate”>Jack</span>!

     </div>

will be extracted for translation as:

     Hello, {0}!

When translated into French, the Smartling service will automatically replace the {0} placeholder with the custom content, so the final output might look like:

    Bonjour, Jack!

The second example can be forced into a pattern match such as:

     <div>

          <span class=”notranslate”>37</span> comments

     </div>

which will extract the content for translation as:

     {0} comments

The third example can be forced into a pattern match as follows:

     <div>

          Page <span class=”notranslate”>1</span> of <span class=”notranslate”>10</span>

     </div>

which will extract the content for translation as:

     Page {0} of {1}

Note: Smartling creates patterns when you use the class “notranslate” within an inline tag only. When you use “notranslate” for a block tag, Smartling ignores the entire block element.

During the translation process, neither professional nor volunteer translators will see the original, variable text; they will see a non-editable placeholder. When the content appears on a translated site, the phrase will appear in the appropriate language, with the placeholder replaced by the actual variable string.

How to Pattern Match Via Configuration

Using translation classes and exclusion classes, you have better control over exactly what is and is not translated (and the translation method).

In cases where it is not possible to modify the specific HTML via the “notranslate” class in an inline element to create patterns, you can write a regular expression describing the pattern, that includes a placeholder for the personalized, unique, or sensitive information.

To demonstrate, consider the following text:

     Thank you, your order number is 56763

This string could be described using the regular expression:

     Thank you, your order number is ([1-9]+)

With this pattern in place, the content will be translated as:

     Thank you, your order number is {0}

because it matches the regular expression above. Smartling can add these regular expression patterns to your site configuration.

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request
Powered by Zendesk