Internationalization (i18n) of content targets both the end user and the node administrator. Messages sent to users and other UI can be internationalized.
Additionally, error messages and administrator-facing UI can be internationalized using the same mechanism for better operator experience.
Internationalized nodes use the locale of the request to find the correct resource bundle, with a default fallback if none is found.
Create a Java resource bundle under the
resourcesfolder 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:
Add the properties and strings that the node will display to the user. For example:
.propertiesfile 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
.propertiesfile could be called
Replicate the properties and translate the values in each
.propertiesfiles. For example:
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"
Define a reference to the bundle using the
getBundleInPreferredLocalefunction to enable retrieval of translated strings:
ResourceBundle bundle = context.request.locales.getBundleInPreferredLocale(BUNDLE, getClass().getClassLoader());
getStringfunction whenever you need to retrieve a translation from the resource bundle:
return send(new NameCallback(bundle.getString("callback.username"))).build();