Building > Translations > Localizing
Localization for CHT applications
Apps built with CHT Core are localized so that users can use them in the language of their choice. Languages supported by default are English, French, Nepali, Spanish, and Swahili. The goal of this doc is to help the community manage these and future translations.
Like the rest of the code the 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 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.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)’”.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.
Localization for CHT applications
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.