Internationalisation

Internationalisation is done at 3 different levels, Java, HTML/JSP and JavScript. All of these rely on the standard ResourceBundle to store the various languages. 

Resource bundles

The resource bundles are located under the step-core project, under src/main/resources/. They split out into various files:

  • HtmlBundle, generally used by the JSP pages, fragments.
  • ErrorBundle, generally the location for most of the error messages
  • InteractiveBundle, generally sources the Javascript messages
  • SetupBundle, generally used by config.jsp & firstTime.jsp

Java

The classes of interest are:

  • ClientSessionProvider: gives access to the current Locale and contains the logic around calculating the Locale, based on cookie/param/header
  • TranslatedException: captures a key and its arguments. These are later processed by the FrontController

There are very few other instances where the Java code needs to localise messages. One example, is the Loader (which initialises all the indexes). This just accesses the ResourceBundle directly by name.

HTML

The following code fragments explain how this is used

TODO

Javascript

In the JavaScript layer, the internationalised messages are exposed under the __s variable. In other words, __s.my_property accesses the my_property key from the InteractiveBundle. This is processed by the com.tyndalehouse.step.rest.controllers.InternationalJsonController whose role is to produce a file containing the language keys used by the client code.

 

Â