Chapter 41. Localization
The portal can localize JavaScript modules on the server. The JavaScript code of each module can be rewritten and localization keys replaced by values from resource bundles for individual locales. Each localized script is available under a different URL, which ensures optimal resource caching.
Script localization is activated by the
<resource-bundle> and <path> elements. Resource bundles are declared by the <supported-locale> element and must be available in the web application's classpath.
Example 41.1. supported-locale Example
<module> <name>greetings</name> <supported-locale>de</supported-locale> <supported-locale>en</supported-locale> <supported-locale>fr</supported-locale> <supported-locale>vi</supported-locale> <supported-locale>ru</supported-locale> <script> <path>/path/to/greetings.js</path> <resource-bundle>greetings_bundle</resource-bundle> </script> ... </module>
The portal escapes all keys in the
${key} format and looks up its value in the resource bundles. For instance, a JSON object containing localized values can be built by the following code:
(function() { return { "hello": "${hello}", "goodbye": "${goodbye}" }; })();
At runtime, different versions of this script will be served by the portal, with the keys replaced by the respective values obtained from the localization bundles.