Localizing dashboard labels
You can localize dashboard labels by attaching XML data (filtered based on the end-user-specified value of a dashboard variable) to the object properties that specify the labels. For a complete localization example, select Localization on the Dashboard Builder Tutorial main page.
To localize dashboard labels
1. Create an XML dataset with a tabular data element. (See
Using XML Data.) Create a column for supported locales, as well as a column for each label. Create a row for each locale. In each row, put a specific locale and the text for each label localized for that specific locale. Here is an example from the Builder tutorial:
<?xml version="1.0" encoding="UTF-8"?>
<dataset xmlns="www.sl.com" version="1.0">
<table key="labels">
<tc name="Locale"/>
<tc name="Confirmation message"/>
<tc name="Press button"/>
<tc name="Are you sure"/>
<tc name="Numeric input"/>
<tc name="Datetime input"/>
<tc name="Numeric display"/>
<tc name="Datetime display"/>
<tr name="English">
<td>en_US</td>
<td>Confirmation message:</td>
<td>Press button</td>
<td>Are you sure?</td>
<td>Numeric input:</td>
<td>Date time input:</td>
<td>Numeric display:</td>
<td>Date time display:</td>
</tr>
<tr name="French">
<td>fr_FR</td>
<td>Message de confirmation:</td>
<td>Bouton-poussoir</td>
<td>Etes-vous sûr?</td>
<td>Entrée numérique:</td>
<td>Entrée date-heure:</td>
<td>Affichage numérique:</td>
<td>Affichage date-heure:</td>
</tr>
<tr name="Spanish">
<td>es_ES</td>
<td>Mensaje de confirmación:</td>
<td>Botón</td>
<td>¿Estás seguro?</td>
<td>Entrada numérica:</td>
<td>Entrada de la fecha y hora:</td>
<td>Exhibición numérica:</td>
<td>Exhibición de la fecha y hora:</td>
</tr>
<tr name="Chinese">
<td>zh_TW</td>
<td>確認信息 :</td>
<td>按鈕</td>
<td>你肯定嗎?</td>
<td>數字輸入:</td>
<td>日期-時間的輸入:</td>
<td>數字顯示:</td>
<td>日期-時間的顯示:</td>
</tr>
</table>
</dataset>
This file defines labels Press button, Are you sure?, and so forth, for the languages English, French, Spanish, and Chinese. The first column Locale defines the locale, or language, of the corresponding row.
2. For each object property that specifies a label, attach the property to the column that corresponds to that label, filtered to select the row for which the value in the locale column is the value of a dashboard variable that specifies the locale desired for the end user. You can use the predefined variable $apama_lang for this purpose. Here is an example:
3. Provide a way for end users to set the relevant variable (for example, the predefined dashboard variable $apama_lang) to their desired locale. One way to do this is to include, on your top-level dashboards, a combo box (from the Controls tab). Attach the selectedValue and varToSet properties of the combo box to $apama_lang, and attach the listValues property to the locale column of your XML data element. Here is an example:
The dashboard substitution $apama_lang is automatically defined for dashboards. Use ISO 639 language codes as values of this variable. This is the same locale string used within Java. See the Java documentation for the java.util.Locale class for more information on locales within Java. Here are some sample locale values:
For dashboards in Builder and Viewer connected directly to the Correlator, the default value for $apama_lang is what Java reports as the locale in the Locale object as derived from the host system's locale.
Locale Name | Locale |
Locale.CHINA | zh_CN |
Locale.CHINESE | zh |
Locale.SIMPLIFIED_CHINESE | zh_CN |
Locale.TRADITIONAL_CHINESE | zh_TW |
Locale.PRC | zh_CN |
Locale.TAIWAN | zh_TW |
Locale.ENGLISH | en |
Locale.UK | en_GB |
Locale.US | en_US |
Locale.FRANCE | fr_FR |
Locale.FRENCH | fr |
For deployed dashboards, the value of $apama_lang is set based on the locale of the host on which the dashboard display server or data server is running. A single dashboard server cannot serve dashboards to users in different languages. Note that number and date formatting performed by the dashboard server are always controlled by the system locale.
Note:
Numeric formats (1,000.00 versus 1.000,00) are controlled by the system locale. You cannot change this by setting $apama_lang. The only way to override it, other than changing your system locale, is through Java system properties. Date/time formats are also controlled by the system locale.