Internationalization

Resource Bundles

Within each module, you will find the file web/cfg/war/bundle/messages.properties. This file is a ResourceBundle containing externalized labels for user interface text. The idea behind ResourceBundles is that all static text appearing in your user interface should be externalized into a properties file. You can then provide multiple versions of this property file to support translations into multiple languages.

Your internationalized labels can be accessed in one of the three ways:

  • Java code can access these values explicitly via com.onenetwork.platform.tools.i18n.MessageBundle. For example:

    MessageBundle bundle = MessageBundleFactory.getMessageBundle();
    String internationalizedValue = bundle.getMessage(platformUserProfile.getLocale(), "my.label.key");
  • JavaScript code can access these values explicitly via the Labels object. For example:

    var label = Labels.get('my.label.key');

    or

    var label = "#my.label.key#";

    The later technique is more performant than the Labels.get() technique. But the later technique also has a limitation, the replacement key can not be determined dynamically.

    var name = "MyLabelName";
    var label = "#meta.field." + name + "#";


    These values will not be replaced when serving the scripts.

    (In this case the locale is not passed because it's implicitly available in the browser as part of the user's profile. See the "Internationalization, Localization and Dates" section of the One Network's JavaScript API documentation for information on how to access internationalized labels from your JavaScript code.)

  • The Platform itself may automatically look-up labels using well-known Label Patterns. For example, Platform provides a feature which shows a list of available actions for a list of selected models. This action list will be internationalized using the Label Pattern meta.actions.modeltype.actionname, for example meta.actions.ZBKS.Book.ZBKS.Publish. You can find out more about Label Patterns below.

Any time you make changes to your messages.properties, you can see these changes take effect in the UI after executing the ant target deploy-and-reload-bundle. (You may have to refresh the browser window to see the change.)