Skip to main content

Setting Up Multiple Languages

Texts and tooltip texts for visualizations are managed in text lists and can be displayed in different languages. To toggle a visualization between the available languages, you need to configure a visualization element with the input configuration for changing the language.

Static texts are automatically managed in the GlobalTextList object. Dynamic texts are managed in explicitly created text lists.

A dynamic text can be modified at runtime by means of a variable which indexes a text list entry. Dynamic texts are often used for the output of variable values or error messages.

Static texts are fixed strings which are used for labels, for example.

For more information, see: Managing Languages and Translations

Note

For Unicode characters to be displayed, the Use Unicode strings option must be enabled on the Settings tab in the Visualization Manager object.

Tip

You can modify the appearance and formatting of texts and tooltips with the element properties Text properties and Font variables.

Configuring language switching for texts from text lists

Client-dependent language

The language can be switched individually for each client. The requirement is that the CODESYS Visualization add-on is installed in at least version 4.7.0.0 and the runtime system in version >= V3.5 SP20. When the visualization is started, it is displayed in the language set in the browser (for example, de or en). This language must be available in the project. If the language is not available, then the default texts are displayed.

In version 4.6.0.0 and lower, the language was switched for all clients simultaneously. 

Requirement: An empty visualization object is inserted into the project and it is open for editing in the visualization editor. There is also a Visualization Manager object. User management is not created for the visualization.

The following instructions provide a simplified example:

  • By means of two buttons, the user should be able to toggle the visualization texts between English and German.

  • Static texts in the visualization include the labels "State, Machine 01", "State, Machine 02", "English", and "German". These texts are located in the GlobalTextList in English and German.

    Dynamic texts will describe the state of both machines. The texts are provided in the text list Status_Texts in English (en) and German (de).

  1. Drag a Text Field from the Visualization Toolbox view (Common Controls category) to the editor view. Specify the value State, Machine M01 in the properties editor for the Texts → Text element property.

  2. Copy the element and change the copy label to State, Machine M02.

  3. See also the figure in Step 14 for the following steps.

    Insert two elements of type Button from the Visualization Toolbox view (Common Controls category) in the visualization editor. With these elements, the user should be able to toggle the language of the visualization. Specify the text German or English in the properties editor for Texts → Text (4) element property.

  4. Double-click and open GlobalTextList in the POUs view.

    The texts are entered in the Standard (1) column, and the IDs 0 and 1 are assigned automatically as additional information.

  5. Add the languages "de" and "en" and localize the default texts with the localization texts shown in the following figure.

    Language code

    Use the ISO 639 code (for example, de, en, it, zh-CHS) to name a language which exists in the visualization.

    _visu_img_localization_globaltextlist.png
  6. Close the GlobalTextList object.

  7. Add two elements of type Rectangle from the Visualization Toolbox view (Basic category) in the visualization editor. The current state of each machine should be displayed.

  8. For managing the texts for describing the states, add an object of type Text List below the application. Name the list Status_Texts.

  9. Specify the texts shown in the figure for the standard language (1) and the target languages en and de in the editor of Status_Texts.

    _visu_img_localization_textlist.png
  10. Close the text list Status_Texts.

  11. Select the rectangle element for displaying the state of machine M01. Select the text list Status_Texts from the combo box in the properties editor (2) for the Dynamic texts element property (5). Specify an application variable for Text index that shows the appropriate text index for the state of the machine at runtime. Example: PLC_PRG.ivar_status_m01.

  12. Now configure the user input for both buttons for toggling the language in the visualization.

    Select the "German" button. Double-click Configure of the property Input configuration (6), OnMouseClick.

    The Input configuration / OnMouseClick dialog opens.

  13. Select Change the language on the left. Click the arrows to accept the setting to the right. Select de in Language to the right of the dialog in the _cds_icon_input_assistent.png Input Assistant. Click OK to confirm.

  14. In the same way, configure the entry for the second button: English: Text list: Status_Texts, Text index: 3, Change the language: English).

    The following figure shows the performed properties configurations for the four visualization elements.

    _visu_img_localization_example.png
  15. When the application is compiled without errors, you can test the visualization in simulation mode. Select the Online → Simulation option. Click Online → Login.

    The visualization appears in the visualization editor view in online mode:

    _visu_img_loc_example_online_en.png
  16. Click the German button.

    The language changes to German:

    _visu_img_loc_example_online_de.png

For more information, see: Switch Language

Setting up fonts for a language

The font for a visualization element is defined in the properties editor. When language switching is provided, you can overwrite this basic font with another font for each language in the Visualization Manager.

Requirement: A visualization is set up with at least one language in addition to the default language.

You can find an example in Configuring language switching for texts from text lists.

  1. Double-click and open the Visualization Manager object and select the Font tab.

  2. Double-click the field in the Font line for a particular language. Select a font from the combo box.

  3. In the Font size line, replace the value 1 with a value greater than 1 (example: 2) in order to increase the size of the font as defined by the visualization style; or replace it with a value less than 1 in order to decrease is (example: 0.5).

    In online mode, the font changes depending on the set language.