Translations file

how set variables and their values in different languages

Use Case: Configuration for Language and Timeout variables

We've got a machine that own this two variables:

String type variables provide a text-field editor when shown in UI. The other types, Integer and Float, are treat as number and UI use a slider control or a drop down menu for editing them.

  • one of the two variable is named LANG

  • the variable LANG, is inside the group GEN_PARAM

  • the variable LANG accepts only six values, from 0 to 5:

    • 0 for Italian

    • 1 for English

    • 2 for French

    • 3 for German

    • 4 for Spanish

    • 5 for Russian

  • the variable LANG is used to set the language of display interface

This is what we want:

Build the translation file

Here above the empty translation file that needs a minimum of 5 column: source, name, field, value and at least one column for the language, here we use en, that is international abbreviation for english. click here to get a sample file ready for language it, en, de

Every column in this file has its own purpose and possible values as here below explained:

Source column

For this purpose source must be always set to "configuration".

Languages columns

every language must have its own column named as its ISO abbreviation.

To translate the english language, that has the en iso abbreviation, we added the column named en right beside the last column, that is value in this case.

If we wanted to translate also language "it", that is italian, we should add also the column "it", in where write the value expressed in Italian language.

Name column

The name column always contains the name of the variable we're translating. Any variable may have different fields to represent properties and be best shown inside the interface: A is for label, B is for description, C are for values (when needed), D is for category name

Field column

the Field column contains the property (as in above paragraph is explained) that you want to translate. Every property has its own purpose:

Label (pos. A)

Label is the string that translates of variable name. So add this line:

Description (pos. B)

Description is used to translate the tooltip that appears when mouse is over the variable name or in any other place the UI uses to the help user understand the content of the variable. So add this line:

Value (pos. C)

Value is used ONLY to translate any possible variable value, when the field column contains the word "value".

E.g. the first two rows of the example files below, can be read as: the configuration variable LANG, when it has the value equal to 0, this in english is shown as Italian the configuration variable LANG, when it has the value equal to 1, this in english is shown as English

The five possible variable values (0,1,2,3,4,5) for the LANG variable are translated in english using respectively the strings Italian, English, French, German, Spanish and Russian.

This means that when the user chooses the label English, Things5 will send the value 1. So add these lines:

Category (pos. D)

Category is used to translate the category variable group name, used only for configuration as shown here So add this line:

Value column

Value column is used when the field column is set to value.

See the above "value" explanation, e.g. looking at the en (english) translations: the line with field-column equal to "value" and value-column equal to "0" is translated as "Italian" and the line with field-column equal to "value" and value-column equal to "1" is translated as "English"

Complete translation file is like this

As you can see the category row GEN_PARAM appears just once in the variable_translation file even if it is repeated in every variable into the machine_variables file, from which we started to set up translation

Sample translations CSV

Below a real translation file that exposes different machine variables translations. To better understand the content of this file, rows has been colored by area and inside those areas rows are colored by variable: blue background is for metrics, red for states, yellow one is for events. Green background is for configuration variables.

Click here to get this file

Last updated