This article covers a Bloomreach Experience Manager version 12. There's an updated version available that covers our most recent release.

Repository resource bundles

This page introduces repository resource bundles, how they are used in the Bloomreach Experience Manager product and how to use them in your own plugins.

Repository resource bundles are used to provide translations for strings that are introduced through configuration in the repository. Examples are:

  • Translations for document type names, fields names and hints
  • Translations for image set names and field names
  • Translations for validator feedback texts

Repository resource bundles are one source for providing translations for the CMS UI. For more details, see CMS UI localization.

Bootstrapping

Repository resource bundles are imported using the configuration management mechanism and can be exported using the auto-export plugin. To import a resource bundle, specify YAML definitions like the following example:

definitions:
  config:
    /hippo:configuration/hippo:translations/myhippoproject:translations
      jcr:primaryType: hipposys:resourcebundles
      /channelmanager:
        jcr:primaryType: hipposys:resourcebundles
        /awesomecomponent:
          jcr:primaryType: hipposys:resourcebundles
          /en:
            jcr:primaryType: hipposys:resourcebundle
            name: value
    /hippo:configuration/hippo:translations/hippo:types/myhippoproject:book:
      jcr:primaryType: hipposys:resourcebundles
      /en:
        jcr:primaryType: hipposys:resourcebundle
        myhippoproject:title: Book title
      /nl:
        jcr:primaryType: hipposys:resourcebundle
        myhippoproject:title: Boek titel

The above example loads several resource bundles providing translations for the document type myhippoproject:book, and for a project specific section for a project specific plugin. The resource bundle can be placed any level deep.

Using resource bundles in code

To use translated labels in Wicket code, the helper class org.hippoecm.frontend.l10n.ResourceBundleModel can be used such as in the following code snippet. This snippet could be used by the fictitious custom plugin in the example in section “Bootstrapping” to load the translation for the key “name” for the locale of the current user:

final String bundleName = "myhippoproject:translations.channelmanager.awesomecomponent";
final String key = "name";
final Label label = new Label("label-wicket-id", new ResourceBundleModel(bundleName, key));

In case the label could not be found due to a coding or configuration error, the ResourceBundleModel returns “???” + key + “???” so you get visual feedback while setting up your Bloomreach Experience Manager project. See also the rules for the ResourceBundle below.

Under the hood, the ResourceBundleModel loads its data using the LocalizationService. It is also possible to call the LocalizationService directly such as in the following code snippet. This snippet shows how to obtain the English resource bundle containing the translations for the fictitious custom plugin in the example in section “Bootstrapping”:

final String bundleName = "myhippoproject:translations.channelmanager.awesomecomponent";
final String locale = "en";

final LocalizationService localizationService = HippoServiceRegistry.getService(LocalizationService.class);
if (localizationService != null) {
    final ResourceBundle bundle = localizationService.getResourceBundle(bundleName, locale);
    if (bundle != null) {
        // ...
    }
}
// …

Conventions

When you examine the resource bundles that are bootstrapped by the product, you’ll notice two conventions:

  • The # character is used to separate a label and a sub label for document field hints. For example when you enable the “blog” feature from Essentials, you see that for the type “myhippoproject:author” a hint is defined for several fields, for instance for “account”: “myhippoproject:accounts#hint”.
  • The = character is used to separate a label and possible sub values, for instance in the resource bundle for the type “hippostd:date” which contains keys such as “hippostd:dayofweek=1”.
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?