If you want to translate/localize/internationalize Find into another language, this article is for you!
How language bundles in Find work
Locale bundles are bundled by webpack, and locale selection happens with a small helper, find/nls/select-locale.
Each translatable area of Find has a “master bundle” module (e.g. find/nls/bundle, find/nls/indexes, find/idol/nls/comparisons) that uses select-locale to pick and merge the right locale module for the current browser locale.
Adding a new language bundle
Let’s translate Find into French.
- Navigate to the Find i18n bundles directory: webapp/core/src/main/public/static/js/find/nls (IDOL-specific bundles live under webapp/idol/src/main/public/static/js/find/idol/nls instead).
- Open the bundle file, e.g.
bundle.jsorindexes.js-rootis the default language, and anen-gbdummy translation has been provided as an example. - Add a new
require()for your locale’s bundle module, and add a matching key to the object passed toselectLocale(). The key should be the RFC 1766 language tag (e.g.fr-cafor French (Canadian),nvfor Navajo, etc). - Copy the
rootdirectory and give your copy the same name as the language tag you have added to the JavaScript files, e.g.fr-ca. - Open and edit all of the JavaScript files in your new folder. Replace the values of each key-value pair with your translations. Make sure that you match up all
"and'characters. - Build and deploy Find. Your translation is now available!
Replacing the default language bundle
The root language bundle is used as a default. Changing the language of the default is as simple as editing the root bundle.
- Follow the steps for “Adding a new language bundle”, to add a new
en-uslanguage bundle, using the existingrootbundle. - Instead of editing your new language bundle, edit the JavaScript files in the
rootdirectory.