Tutorial: Multilingual visualization project

Introduction

Sometimes it is necessary to provide a visualization project in different languages. The language is either predefined by the integrator or, depending on the implementation, the user can change the language during runtime.

This tutorial shows how to implement and configure the language translation. Refer to variables in a visualization project for general information on variables in visualization editor.

How it works

Translation file

The central element for the language translation is the translation file nxaTextTranslation.xlsx which contains the translations.

To open the translation file directly from the Visualization Editor, click Edit > Edit Translation Table in Excel... from the menu.

The translation file must contain at least 2 columns:

  • The TEXT column, which is the key.

  • One additional column for each supported language. The column header in the first row must contain the language code.

TEXT

DE

EN

LANGUAGE_3

LANGUAGE_4

LANGUAGE_5

TEXT

DE

EN

LANGUAGE_3

LANGUAGE_4

LANGUAGE_5

_ROOM

Zimmer

Room







_LIGHT

Licht

Light







_ON/OFF

Ein/Aus

On/Off







_STATUS

Status

Status







_MUR

Aufräumen

Make up room

 

 

 

_DND

Nicht stören

Don't disturb







_ROOMSTATUS

Zimmerstatus

Room status







_WEATHER

Wetter

Weather







_UP

Auf

Up







_DOWN

Ab

Down







_SUNNY

sonnig

sunny







_CLOUDY

wolkig

cloudy







_RAIN

Regen

rain







_SNOWING

Schneefall

snowing







_STORM

Sturm

storm







_UNDEFINED

unbekannt

undefined







Syntax for language translation in visualization editor

In the visualization editor, each text, which needs to be translated, must be written in the syntax {TT:<TEXT>}, e.g. {TT:_ROOM}.

Setting the language

In the visualization editor, the predefined workspace variable NXA_LANGUAGE holds the code of the language to show, e.g. NXA_LANGUAGE=EN to show the English translation.

If there is no translation for a used TEXT, then the key from the TEXT column is displayed in the visualization.

Best practice for naming the key is to write the key in upper case or using underscores at the beginning. Missing translations can be found easier then.

Step by step

Let's assume that a room controller should be available in different languages. The room controller page contains several label, button, multi text and drop down objects to be translated and 3 buttons to switch between the languages. 

  1. Create a new visualization workspace or open an existing one.

  2. Edit the translation file <install-dir>\Visualization\Workspaces\<workspace-name>\DataFiles\nxaTextTranslation.xlsx and set up the TEXT keys, the language codes and the respective translations.

    • If the file does not exist, copy the linked file from this document to the folder.

    • Ensure to have full access to the folder to store or change the nxaTextTranslation.xlsx file

  3. In visualization editor add e.g. a Label object to the page. 

    1. Open Label parameters dialog

    2. On the Object tab, set Function = Text

    3. On the Appearance tab, set Text{TT:_ROOM}.


  4. Add other objects e.g. buttons in the same way.

  5. Add 3 Button objects to the page for choosing the language. For each button:

    1. Open Button parameters dialog

    2. On the Object tab, set Function = XCommand Button

    3. In the XCOMMAND column click  and
      set XCommand = VISU.WORKSPACE.SETVARIABLES
      set VariableName_1 = NXA_LANGUAGE

  6. Alternatively, instead of using buttons to select the language, the language setting can be retrieved from a Server Item.

    1. Set the workspace variable NXA_LANGUAGE to {IV:<your-server-item>}, e.g. {IV:NETx\VAR\String\Item001}.

    2. Set the respective Server Item to EN, DE, or FR to show the desired language.

  7. Save and run the visualization.

The example translation file contains columns for English and German but not for French. Therefore, when selecting French then the untranslated keys will be displayed.

Animation

Downloads