Building > Translations > Localizing
Using the CHT in the desired language
Apps built with CHT Core are localized so that users can use them in the language of their choice. The goal of this section is to help the community manage existing and new translations.
Translation files live in the GitHub repo. These translation files are properties files, which are a series of keys and their corresponding values. The English file is used by default, and as such, it contains the entire set of keys. If any key is missing from another language file the English value is used.
New elements in CHT apps, such as tasks, targets, profiles, and forms should be localized as well. These labels should be included in the same custom translations properties file. If a translation is missing for the user’s language it will use that of the default language.
New languages must be added and configured in several places:
messages-xx.properties
file in the api/resources/translations
folder, replacing “xx” with the 2 or 3 letter language code. The language code will be used to identify the language in the application. For instance, for English, we would have a translations/messages-en.properties
file.LOCAL_NAME_MAP
in api. Use the language code for the key, and the local name followed by the English name for the language in brackets, eg: “fr: ‘Français (French)’”.TRANSLATIONS
entry for the new language in the translator.js file.messages-en.properties
. Using existing keys when possible reduces the effort required to translate the app into a new language.npm run lint-translations
.In angular this is done using angular-translate, and ideally using the translate directive to reduce the number of watchers, eg: <h3 translate>date.incorrect.title</h3>
.
Use the translation functions in the config module in API and Sentinel.
Much of the app is configurable (eg: forms and schedules). Because the specifics of the configuration aren’t known during development time, these can’t be provided via messages. Instead configurers can provide a map of locale to value for each translated property. Then use the translateFrom
filter to translate from the configured map using the user’s language.
npm run lint-translations
.Carefully verify that the translation key isn’t used. This can be challenging if keys have been concatenated or generated because then you won’t be able to find the complete string in the source code. Once this has been confirmed, then simply remove the key and value from all translation files.
Using the CHT in the desired language
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.