![]() |
Open Test Framework
|
|
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.
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:
TranslationKey
is stored inside the MetaData the TranslationKey
can only be used at the interface to the environment and not inside OTX.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.
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
Sample TextIdMapping for the sample below:
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:
TranslationId
. If the TranslationKey
cannot be mapped to a TranslationId
, the TranslationId
is equal to the TranslationKey
.TranslationId
MappingTranslationId
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
, theTranslationId
is equal to theTranslationKey
.
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
.
TranslationId
TranslationId
to a localized text of the selected language A, B or C and return it as a result of the translationThe 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 |
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
):
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
):
American English (en_US.json
):
British English (en_GB.json
):