Access Management 7.3.2

Internationalization

Internationalization (i18n) of content targets both the end user and the node administrator. Messages sent to users and other UIs can be internationalized.

You can also internationalize error messages and administrator-facing UI using the same mechanism for better user and admin experience.

Internationalized nodes use the locale of the request to find the correct resource bundle, with a default fallback if none is found.

Localize node UI text

  1. Create a Java resource bundle under the resources folder in the Maven project for your node.

    The path and filename must match that of the core class that will use the translated text.

    For example, the resource bundle for the Username Collector node is located in the following path: src/main/resources/org/forgerock/openam/auth/nodes/UsernameCollectorNode.

    The resource bundle for the username collector node as displayed in the project window in the IntelliJ IDE.
    Figure 1. Example resource bundle
  2. Add the properties and strings that the node will display to the user.

    For example:

    callback.username=User Name
  3. Create a .properties file in the resource bundle for each language your node will display.

    The filename must include the language identifier, as per rfc5646 - Tags for Identifying Languages.

    For example, for French translations your .properties file could be called UsernameCollectorNode_fr.properties.

  4. Replicate the properties and translate the values in each .properties files.

    For example:

    callback.username=Nom d'utilisateur
  5. In the core class for your node, specify the path to the resource bundle from which the node will retrieve the translated strings:

    private static final String BUNDLE = "org/forgerock/openam/auth/nodes/UsernameCollectorNode";
  6. Define a reference to the bundle using the getBundleInPreferredLocale function to enable retrieval of translated strings:

    ResourceBundle bundle = context.request.locales.getBundleInPreferredLocale(
            BUNDLE, getClass().getClassLoader());
  7. Use the getString function whenever you need to retrieve a translation from the resource bundle:

    return send(new NameCallback(bundle.getString("callback.username"))).build();