Skip to content

Internationalization

Wayne Graham edited this page Jun 30, 2017 · 6 revisions

Blacklight uses the Rails i18n framework to provide multilingual version of most text in the Blacklight default templates. Blacklight ships with a set of English and French translations in config/locales.

In addition to multilingual support, developments can also e.g. customize the English strings in Blacklight-based applications, which provides a way to change text without overriding templates and partials.

A quick i18n example

A locale entry that looks like this:

en:
  blacklight:
    application_name: 'Blacklight'

Is referenced in the Blacklight code as:

I18n.t 'blacklight.application_name'
# OR
t('blacklight.application_name')

You could override this in your application's config/locales/en.yml:

en:
  blacklight:
    application_name: 'My Blacklight Application'

And then everywhere Blacklight views show the application name, it will use your label ("My Blacklight Application") instead of ours ("Blacklight").

Those wanting to use Blacklight internationalization will also want to add the rails-i18n gem to their application. This gem provides additional Rails locale data not found in Blacklight.

There are other i18n tricks (that we use) covered in the Rails i18n Rails guide, including pluralization, interpolation, etc.

Clone this wiki locally