Copyright © 2002 Bernhard Woehrlin, IT.CappuccinoNet.com
StrutsCX renounces the Java Resource Bundle technique and simply uses XML technologies for internationalize web applications:
Instead of the ApplicationResources.properties it uses XML files, like Struts. One for each language. Subsequently these files are called Resources-Properties. Other than by using the Java Resource Bundle the consistency can be checked by DTDs or XML Schema.
<variables lang="de">
<strings>
...
<day>Tag</day>
...
</strings>
...
</variables>The StrutsCX Resources-Properties can be filed outside the classpath. Like all the files you like to hide before the direct access via HTTP, it's best to put them somewhere inside the /WEB-INF folder.
XML uses UTF-8 as standard encoding and offers access to letters in all languages including Chinese, Korean, Arabic etc. The StrutsCX-Resources-Properties benefits from this.
Like always in XML you can organize the content hierarchically.
Translators can use modern XML Editors to edit comfortably the content of the XML files. There is no similar comfort by editing the Java Resource Bundles.
In StrutsCX all configuration files are XML based. There is no mix of Java properties and XML properties like you have in Struts.
The StrutsCX Resources-Properties is not read in with the ActionServlet. Therefore inside the web.xml the initialization parameter to read in the ApplicationResources.properties is obsolete. StrutsCX gets its initialization information out of the properties.xml, the special StrutsCX configuration file. During the first call of an Action class the Resources-Properties files will be read in as org.jdom.Documents and get added to the ServletContext. One file for each language.
StrutsCX does not supports the {}-Syntax of the java.text.MessageFormatclass, which can be utilized in the Struts ApplicationResources.properties. But not yet all possibilities of XML technologies are taken in account.
StrutsCX manages the language the Client chose inside the java.util.Locale object. Depending on the appropriate language the Resources-Properties are added to the XML-Output-Document. Inside the XSL Stylesheets the View can use this values easily. But instead of a special JSP-Tags a W3C standard XSLT/XPath expression is used:
<xsl:value-of select="//variables/strings/day"/>