Open Test Framework  
Text Library Window

The Text Library Window lists all explicit and implicit TranslationKeys found in the solution and presents them in a structured manner. If required, the TextId Mapping can be edited.

General (TranslationKey)

The OTX i18n extension supports multilingualism. I18n stands for "internationalization". It provides data types, terms and actions for translating strings to the language of a certain locale. Translation means that one or more localized texts are assigned to one unique TranslationKey and instead of using the localized text, the TranslationKey will be used. TranslationKeys can exist in the following manner:

  1. As a declaration of data type TranslationKey
    The declaration can be used inside OTX and also at the interfaces to the environment, like a ScreenSignature or a procedure InParameterDeclaration.
  2. As an explicit TranslationKey of an EnumerationElement
    Due to the TranslationKey is stored inside the MetaData the TranslationKey can only be used at the interface to the environment and not inside OTX.
  3. As an implicit TranslationKey of an EnumerationElement
    If an EnumerationElement does not declare an explicit TranslationKey, see above, the EnumerationElement has an implicit TranslationKey, which can also only be used at the interface to the environment and not inside OTX. The implicit TranslationKey is equal to the full qualified name of the EnumerationElement, e.g. i18nPackage1.Document1.Color.Green.

Note: The intension to use a TranslationKey for an EnumerationElement is to translate the often used enumeration values outside of OTX in a human-readable manner.

TextId Mapping

The localized text is stored in Text Tables. Each locale has an own table. The text tables are in the responsibility of the target system. To separate the TranslationKey used in OTX and on the interfaces, an optional mapping layer exists. The mapping layer ist based on a TranslationId. The mapping layer is called "TextId Mapping". Inside the TextId Mapping the TranslationKey is mapped to a TranslationId. The mapping is optional. Inside the translation table the TranslationId is mapped to the localized text.

Note: The TextId Mapping is optional and can be switched off if not needed. If switched off, the TranslationKey is searched for in the text table.

The TextId Mapping is stored inside the i18n folder of the project. The file has the following filename and format:

ProjectName.tidMap

{
"TextIdMapping": {
"TranslationKeyName_1": "TranslationIdName_1",
"TranslationKeyName_2": "TranslationIdName_2",
...
"TranslationKeyName_n": "TranslationIdName_n",
}
}

Sample TextIdMapping for the sample below:

{
"TextIdMapping": {
"TranslationKey_1": "TranslationId_1",
"TranslationKey_2": "TranslationId_2",
"TranslationKey_4": "TranslationId_4",
}
}

Translation

To use a localized text from a TranslationKey, the TranslationKey must be translated. Translation means: return a localized text string from a TranslationKey. The translation will not be done implicit. It must be done explicit. The translation inside OTX must be done by the Translate term and the translation at the interface (outside OTX) must be done by the method Translate of the Ii18nImplementation of the OTX-Runtime API.

There are two mappings with the following special rules:

  1. TextId Mapping
    Maps the TranslationKey to a TranslationId. If the TranslationKey cannot be mapped to a TranslationId, the TranslationId is equal to the TranslationKey.
  2. TranslationId Mapping
    Maps the TranslationId to a the text inside a text table. The right text table will be selected by the OTX-Runtime. It can be the locale of the operation system or a certain locale selected by the author. If the TranslationId cannot be mapped to a text, the TranslationId itself is returned.

Important: If the TranslationKey is not mapped to a TranslationId, the TranslationId is equal to the TranslationKey.

Important: If no text is found the translation table the TranslationId is returned.

The following picture show the translation. In the example are 4 TranslationKeys and 3 text tables, a default text table and tables for the locales en_US and en_GB.

  1. Step: Calls the translation method (in OTX or at the API)
  2. Step: Maps the TranslationKey to a TranslationId
  3. Step: Maps the TranslationId to a localized text of the selected language A, B or C and return it as a result of the translation
Translation from a TranlationKey to a localized text via two mappings (Starts with 'Step 1' on the right)

The following table shows the result of the sample translation above.

TranslationKey String for default language String for en_US String for en_GB
TranslationKey_1 Brakes Brakes Brakes
TranslationKey_2 Truck Truck Lorry
TranslationKey_3 Life can be so easy TranslationKey_3 TranslationKey_3
TranslationKey_4 Gas Gas TranslationId_4

Text Tables

The text table assigns a text to a TranslationId. The mappings of TranslationId to text are grouped in named categories. The TranslationId and the category name inside one text table must be unique.

Note: The categories have no influence on the translation.

Note: All text tables can be edited inside the Text Library Editor.

Text table file format (filename xx-XX.json):

{
"CategoryName_1": {
"TranslationIdName_11": "Localized text",
"TranslationIdName_12": "Localized text",
...
"TranslationIdName_1n": "Localized text",
}
"CategoryName_2": {
"TranslationIdName_21": "Localized text",
"TranslationIdName_22": "Localized text",
...
"TranslationIdName_2n": "Localized text",
}
...
"CategoryName_n": {
"TranslationIdName_n1": "Localized text",
"TranslationIdName_n2": "Localized text",
...
"TranslationIdName_nn": "Localized text",
}
}

The text tables are stored in JSON files. Each language in one file. The folder in which the files are stored can be freely chosen. The default folder is:

c:/Users/Public/OpenTestSystem/i18n/TranslationLib/

Filename format:

xx.XX.json

The filename of a text table consists of the ISO 639-1 standard language code and the file extension "json", like "en-US.json" or "en-GB.json". The default language has the filename "Default.json".

Note: In OTF the settings of the i18n extension can be edited in the solution settings, see i18n settings.

Sample text tables for the sample above:

Default language (Default.json):

{
"Category_Automotive": {
"TranslationId_1": "Brakes",
"TranslationId_2": "Truck",
"TranslationId_3": "Engine"
"TranslationId_4": "Gas"
"TranslationId_5": "Tires"
}
"Category_Others": {
"TranslationKey_3": "Life can be so easy"
}
}

American English (en_US.json):

{
"Category_Automotive": {
"TranslationId_1": "Brakes",
"TranslationId_2": "Lorry",
"TranslationId_5": "Infotainment"
}
}

British English (en_GB.json):

{
"Category_Automotive": {
"TranslationId_1": "Brakes",
"TranslationId_2": "Lorry",
"TranslationId_5": "Infotainment"
}
}