To create a multi-language application you have to create an own grammar rule set for each language. In the tutorial you can see how to set up a new grammar rule.
If you have a GUI that should display a button label based on the language, or you want to make the TTS speak a text in the current language, you can create “Localization rules”. To create such rules you have to create a new SiAM-dp-model in the folder “localization” located in the resource-folder. The localization has a property to define the language. Here you have to enter the language-code (de-DE for german for example) to use it in the desired language. The localization rules are mappings from a key to a specific sentence. In multi-language applications you have to create a localization mapping for each language. It is important that the key for a specific sentence is the same in all languages.
in german localization: lampIsOn -> Die Lampe ist eingeschaltet.
in english localization: lampIsOn -> The lamp is already on.
“lampIsOn” is the key which is needed to know which sentence should be used. The platform now chooses the value by the language which is set in the platform.
To use those rules in the GUI, you have to set the label-property in the GUI-element to “$expr(ResourceManager.getString(“lampIsOn”))”.
Note: The argument in getString has to be set to the desired key. In our example this is “lampIsOn”.
In order to use localization in TTS, you have to create a speech-output in the dialogue and then set the utterance-property to “$expr(ResourceManager.getString(“lampIsOn”))”.
Changes are made equally to the steps above.
You can only use one language while your application is running. For setting the language open the configurations folder in the project folder. Here you have to open the file „de.dfki.mmds.core.resourcemanager.properties”. Change the value of LANGUAGE to the desired shortcut. (de-DE for German or en-US for English e.g.)
- You can also specify the language in the program arguments when starting the executable file. Use the property -language <LANGUAGE-CODE>, e.g., -language de-DE for german. This setting overrides the setting in the property file.
- You can change the language during runtime by changing the property file.