JBoss Community Archive (Read Only)

GateIn Portal 3.8

GMD Localisation

GateIn can localise modules on the server: the JavaScript of each module is rewritten and replace keys by values borrowed from resource bundles. Each script will be available under a different URL for each localisation to provide maximum caching of the resource.

The localisation of a script is activated with the resource-bundle XML tag along with the path tag. Resources bundles are declared by the supported-locale tag and must be available in the web application classpath:

<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>

GateIn will escape any key of the form ${key} and will look up the value in the resource bundles. For instance one can build easily a JSON object containing localised values:

greetings.js
(function() {
  return {
    "hello": "${hello}",
    "goodbye": "${goodbye}"
  };
})();

At runtime different versions of this script will be served by GateIn with the properly escaped values.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 13:20:44 UTC, last content change 2014-04-15 06:43:07 UTC.