Purpose and Benefits
Multi-Lingual Support (Internationalization) provides a way to make the application available in multiple languages. Internationalization is also referred to as i18n because there are 18 characters between 'i' and 'n' in the word 'internationalization'. Bahmni provides support for internationalization with minimal configuration changes.
Internationalization of the product pages is supported through the app config files. These files can be accessed here.
Steps
1. Add a locale in OpenMRS
OpenMRS uses a setting called locale.allowed.list to keep track of the list of supported locales. The setting can be changed using the OpenMRS Advanced settings. This setting contains a comma separated list of locales. To add a locale, add it after the last one, and remove any locale that is not supported. For example, en, es, fr, it, pt, etc.
The list of supported locales will then show up as a drop down list on the Bahmni Home page.
{"locales": [ {"code": "en", "nativeName": "English"},
{"code": "es", "nativeName": "Español"},
{"code": "fr", "nativeName": "Français"},
{"code": "it", "nativeName": "Italiano"},
{"code": "pt", "nativeName": "Português"}]
}
If you don't specify the language mapping for the locale code in localeLanguages.json, the code itself will be displayed.
2. Add files for the locale in bahmniapps
There is a folder called i18n in the bahmniapps folder which contains all the files required for the locale. The directory structure reflects the various modules in the application. Each module has JSON files supporting different locales.
What do the JSON files contain?
The JSON files contain a JSON object consisting of key-value pairs. All the keys are internally mapped to the text that is displayed in the module's web page to which the JSON file belongs to.
{
"BAHMNI_PAGE_TITLE_KEY": "Bahmni Home",
"LOGIN_LABEL_LOGIN_KEY": "Login",
"LOGIN_LABEL_USERNAME_KEY": "Username",
"LOGIN_LABEL_PASSWORD_KEY": "Password",
"LOGIN_LABEL_LOCATION_KEY": "Location",
"LOGIN_LABEL_LOGIN_ERROR_MESSAGE_KEY": "You are not authenticated or your session expired. Please login.",
"LOGIN_MESSAGE_ENTER_USERNAME_KEY": "Enter your username",
"LOGIN_MESSAGE_ENTER_PASSWORD_KEY": "Enter your password",
"LOGIN_LABEL_SELECT_LOCATION_KEY": "Select Location",
"LOGIN_LABEL_SELECT_LOCALE_KEY": "Select Locale",
"HEADER_LABEL_LOGOUT_KEY": "Logout"
}
The JSON files should be created in bahmniapps --> i18n folder.
To get started, you can just copy existing locale file and rename it.
Internationalization of product pages can also be achieved through Overriding Config
Performing complete translation:
Bahmni application by default supports English locale. It comes bundled with locale_en.json files for all modules. These files contain keys that correspond to the text inside the application. So, an implementer can't directly access those files. Instead you can access them at https://github.com/Bhamni/openmrs-module-bahmniapps/tree/master/ui/app/i18n. Copy all keys corresponding to the module into the locale file and translate all those text values also.
3. Download the translated locale files from Transifex:
One can download and use bahmniapps locale files that are available in Bahmni project on the Transifex website. One can also contribute to the Bahmni Project on Transifex by translating. For more information on contributing to Bahmni check this Translating Bahmni page.
Enable Language Switch in OpenELIS / Lab
Currently OpenELIS only supports English & French language (for some screens). To see the Language Switch option in OpenELIS login page, turn on the below mentioned flag, by firing an Update statement in OpenELIS database:
UPDATE clinlims.site_information set value=true where name='allowLanguageChange';
You can also configure the default language you want to see by firing an update statement in OpenELIS database:
UPDATE clinlims.site_information set value='fr-FR' where name='default language locale';
To pull new language from transifex, follow readme in OpenELIS repository.