Add languages¶
drag&bot natively supports translations for the English and German language. But it is possible to provide translations for additional languages. This can be used to translate static texts in drag&bot to a new language. If you want to translate dynamic, application specific texts (like I/O names) please take a look at the application translations feature. To translate any texts in your programs or function blocks please take a look at the chapter function block translations
Determine the language ID¶
The language ID is used to identify a language. It always contains the two letter code 🔗 for the language. In most cases it is sufficient to specify only the language code. But if you want to differentiate how the language is spoken in different locations, you can add a region. Regions 🌍 are appended to the language and separated by a hyphen.
Examples:
- de → German
- en → English
- en-US → English as it is spoken in the US
- es-MX → Spanish as it is spoken in Mexico
Adding new language files¶
To add a new language you need to add a json file providing the translations. This GitHub repository 💻 contains translation files used in different versions of dragandbot.
To create a new language file for your own language:
- Choose the directory for your version in this GitHub repository 💻
- Download one of the files e.g.
en.json
as a template - Replace the translation values in the file with for your language
- Rename the file to
{language_ID}.json
. (e.g.fr.json
) - Copy the file to
/workspace/application/dragandbot/dnb/language_files/json/
on the controller directory
Development workflow
When making changes to the {language_ID}.json
you can just refresh the page (Keyboard shortcut: 🔲 F5) to see changes. It may be necessary to clear the cache of your browser. In the most browsers it can be done with the keyboard shortcut:
- 🔲 CTRL + F5 or
- 🔲 CTRL + SHIFT + F5
Language config: language_config.json
¶
To register the new language you also need to create the config file language_config.json
in the /workspace/application/dragandbot/dnb/language_files/
directory. The config file has two properties. Both are optional.
Property | Description |
---|---|
preferredLanguage | the preferred language which will be used if no language was selected previously. (default is en => English) |
languages | an array of additional language (default is []) |
New languages are added in the languages array. Each entry consists of these properties. Both are required.
Property | Description |
---|---|
id | Language ID (if this is more than 5 or less than 2 letters the entry is ignored) |
name | The name with which the language is displayed to the user in the language selection. |
In this example, French has been added to the existing list consisting of English and German:
{
"preferredLanguage": "fr", //(1)
"languages": [
{
"id": "fr", //(2)
"name": "Francais"
} //(3)
]
}
- Set french as your default language.
- Possible selection examples :
fr
,en
,en-EN
,es-ES
,de-DE
, ... - Add more translation objects to this array if necessary