Please enable JavaScript to view this site.

CWT User Interface Design Handbook

Navigation: Language

Translation

Scroll Prev Top Next More

Translations are specified in the file translation.xml which contains sets of key-value pairs. A set is like a lookup table. The key-value pair defines a text string identified by the key. The different sets are identified by a language code.

Note:
The keys in the standard configuration are always in English

When defining a user interface component, instead of assigning a static text it is given a key where the key has different corresponding text strings depending on the currently selected set (language).

Below is an example of a translation file with three keys that can be assigned to Help-, Accept-, and Reject-button instead of assigning static text in the user interface. When the language is changed to Swedish (se-SE) the Help-button text will change to “Hjälp”:

<?xml version="1.0" encoding="utf-8"?>
  <languages>
    <language code="default">
        <data key="help" value="Help" />
        <data key="accept" value="Accept" />
        <data key="reject" value ="Reject" />
    </language>
    <language code="de-DE">
        <data key='help' value='Hilfe'/>
        <data key='accept' value='Akzeptieren'/>
        <data key='reject' value='Abbruch'/>
    </language>
    <language code="sv-SE">
        <data key='help' value='Hjälp'/>
        <data key="accept" value="Köp" />
        <data key='reject' value='Avbryt'/>
    </language>
  </languages>

Assigning translation keys to user interface components are made by properties named “Name”, “Text” or “Formattedtext” depending on component. For labels and buttons the whole string in the property “Text” is treated as a translation key. For label there is a special property named “FormattedText” which handles translations and is described further in Dynamic label text.

To select different translation sets (change language code) there are a group of button click functions with names starting with “OnLanguage…”. See Button click-function for further details.

Note:
Use <E> to add a new line in  a text.
If you do this make sure that you have enough space to display more lines in the object.
See the object you want to use for details on multiple lines

example

<data key='help' value='Use<E>help'/>