-
Notifications
You must be signed in to change notification settings - Fork 38
Translating Find
If you want to translate/localize/internationalize Find into another language, this article is for you!
Find uses Require.js for loading JavaScript modules. Require has a i18n
(short for "internationalization") module for translating web applications. The documentation is here.
When a user navigates to the Find web application, the Find code "requires" the internationalization bundle. Internally, the i18n
plugin reads the browser's locale and checks to see if there is a translation for that language - if there isn't, the default language bundle is used.
Let's translate Find into French.
- Navigate to the Find i18n bundles directory: core/src/main/public/static/js/find/nls/root/
- Open
bundle.js
- this is the master list of all translations -root
is the default language, and anen-gb
dummy translation has been provided as an example. - Add a new key-value pair to
bundle.js
. The key should be the RFC 1766 language tag (e.g.fr-ca
for French (Canadian),nv
for Navajo, etc). The value should betrue
, to enable the new translation. - Add the same key-value pair to
errors.js
andindexes.js
. - Copy the
root
directory 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 - using a tool like JSLint to check your syntax would be a good idea here (expect it to produce warnings, but keep an eye out forUnclosed string.
messages) - Repeat steps (5) and (6) for the secondary i18n bundles directory: idol/src/main/public/static/js/find/idol/nls/root/
- Build and deploy Find. Your translation is now available!
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-us
language bundle, using the existingroot
bundle. - Instead of editing your new language bundle, edit the JavaScript files in the
root
directory.
Custom sort options can be configured in the configuration file (search.sortOptions
property). To translate these, use the value null
for the label
property, and define a translation string search.resultsSort.<option ID>
.
For example, the sort option "author": { "sort": "author:increasing", "label": null }
can be translated using the translation string search.resultsSort.author
.