In MyRobotLab you can set the Locale for all services in the Runtime service panel. Or in Python with runtime.setLocale(code) where code is "en-US, fr, it-IT or any valid locale code.
MyRobotLab, we support having different translations for certain info , error, and status types of messages in myrobotlab.
- Language specific strings are stored per service by default in the resource/ServiceType/localization directory. (replace "ServiceType" with the type of service InMoov2 for example.
- The files with the localized (translated) strings will be in standard java properties format. key=value (one per line, with comments starting with a # sign.)
The 2 digit language code is used for the language specific filenames. for example: en.properties, or fr.properties
- Runtime defines the locale / language for MyRobotLab. Example: runtime.setLocale("en-US")
Looking up the string will be using the "localize" method on services. Example: i01.localize("BATTERYLEVEL") There is only a single localization file per language. These will all be consolidated into a single file named "en.properties" in the resource/InMoov2/localization folder.
- If a translated label isn't found on the service, it will fallback to see if there's a match for that label defined for the Runtime service.
- If a language specific match for the label can't be found, we will fallback and return the english localized version (and potentailly we should log a message asking someone to help us translate that label.)
And that would look up the string to use for "BATTERYLEVEL" in the current language (locale) that the bot is set to operate in.
Matching Precidence could/should be as follows:
- Match Service with current Locale of the Runtime service
- Match Service with Default (english) Locale
- Match Runtime with current Locale of the Runtime service.
- Match Runtime with Default (english) Locale
Some additional comments about the keys used in the properties files.. they should be:
- alpha numeric only.
- no white space characters
- case insensitive
- should not contain an equals sign in the key
- generally, easy to read/understand as a human
Runtime.setAllLocales('en') will set all running services Locales to the new value.
When MRL starts I had Runtime.setLocale('fr') - all subsequent services will default to the same locale value.
While the filter is running I can Runtime.setAllLocales('es') and all (including OpenCV) locales will switch.