Client Side Translation (CSX)

GlobalLink Web Proxy CSX facilitates asynchronous communication with a GlobalLink Web Proxy TM service and retrieve translations directly from the browser.

Normally, the GlobalLink Web Proxy translates all the text for a website as the content passes through the proxy. When it is difficult or impossible to correctly unpack, parse, and translate content as it passes through the proxy, CSX may be a solution. CSX is a set of client-side code that can translate HTML elements after the page loads and has completed client-side DHTML modifications.

It is still preferable to translate using the proxy because depending on the CSX method that you choose, there may be a noticeable flicker while text on a web page renders initially in its original language and CSX replaces the original-language text with translated text.

• Before GlobalLink Web Proxy CSX can be used, Translations.com will need to properly configure the GlobalLink Web Proxy to use CSX.

• CSX is not automatic. Elements on each page that need to be translated need to be identified and configured to use CSX.

CSX Modes

There are three CSX modes (specify the mode as a quoted, case sensitive string before invoking the Translate method):

  • XX
  • LocalTM
  • OTX

The “XX” Mode

This mode should always be your first step when using CSX. Use the XX mode to check that you have correctly identified CSX as a solution to your translation challenges. The CSX JavaScript code will convert any and all text that you identify with the OneLinkCSX.Translate( ) method to "X" and "x" characters. No actual TM needs to be built and no services are consulted for this operation. After translating content with the XX mode, you can choose one of the other two approaches.

Translations.com recommends the LocalTM mode if you have only a small handful of segments to translate (fewer than 10). More than 10 segments will probably become unwieldy, making the OTX mode the better solution.

The “OTX” Mode

This mode tells GlobalLink Web Proxy CSX to use AJAX to communicate with the GlobalLink Web Proxyserver for all its translations. Webpage flicker may be more noticeable using the OTX mode than with either the XX or LocalTM mode. Each invocation to the OneLinkCSX.Translate( ) method will result in one round-trip AJAX call to the server. In OTX mode, all translatable text is in the GlobalLink Web Proxy TM and not hardcoded in JavaScript files. Also, numeric localization, tokenization, termification, and active monitoring will work with OTX but not the other modes.

The “LocalTM” Mode

Use this mode when you need to translate 10 strings or less. The LocalTM mode involves hardcoding strings in each onelink-csx.js file. Note that any strings that are in a JavaScript file cannot be managed by the Project Manager; so, use this approach for small data sets only. In addition, Translations.com must manually build the TM by copying and pasting segments (and their translations) into the corresponding onelink-csx.js file.

How to Identify Text for Translation

After setting up CSX, you will need to add Translate( ) methods to your onelink-csx.js include file. There will be many ways you can isolate the text to be translated. Try to pick specifications that minimize the number of calls to Translate( ). You can make use of jQuery DOM selectors:

OneLinkCSX.Translate("#menu");              
// translate the innerHTML of the element with id="menu" found on any page

OneLinkCSX.Translate(".catalog");           
// translate the innerHTML of every element (on every page) that has class="catalog"

OneLinkCSX.Translate("li");                 
// translate the innerHTML of every <li> element (on every page)

OneLinkCSX.Translate("ul.topnav> li");     
// translate the innerHTML of every <li> element (on every page) that is a child of a <ul> element having the class "topnav"

By default CSX will process all of your web pages. Occasionally, you will need to restrict its activity (or some of its translation operations) to certain URLs. For this reason, the Translate( ) method takes an optional second argument which is a regular expression applied to the current URL.

Examples:

OneLinkCSX.Translate(".catalog", "productPage");           
// translate the innerHTML of elements that have a class="catalog" - on pages with "productPage" in the URL

OneLinkCSX.Translate("li", "productPage");                 
// translate the innerHTML of every <li> element - on pages with "productPage" in the URL

How to Build a LocalTM in JavaScript

If you choose the "LocalTM" mode, right after setup and before any calls to Translate, you will need to build source/target pairs in each language's onelink-csx.js file:

OneLinkCSX.AddToLocalTM ("the text to be translated", "the translation");

For each string to be translated, you will need to add one of these statements.

Since JavaScript is doing the replacement (and not the GlobalLink Web Proxy), the segments will not be segmented and will match whatever is in the DOM. Also, normal tokenization rules will not apply. For example a string such as "3 items cost you $12.00" will have to go in the local TM, and neither number will be tokenized.

Language Names and Codes

Language Names, Selectors, and ISO Codes (639-1)1

Language Language Selector Code
Arabic العربية ar
Chinese Simplified:简体中文 Traditional:繁體中文 zh
Croatian Hrvatski hr
Czech Čeština cs
Danish Dansk da
Dutch Nederlands nl
English English en
Finnish Suomi fi
French Français fr
German Deutsch de
Hebrew עברית he
Hungarian Magyar hu
Icelandic Islenska is
Italian Italiano it
Japanese 日本語 ja
Korean 한국어 ko
Latvian Latviski lv
Norwegian Norsk no
Polish Polski pl
Portuguese Português pt
Russian Русский ru
Spanish Español es
Swedish Svenska sv
Turkish Türkçe tr

For a complete list of language and country codes see the Unicode Common Locale Data Repository.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.