ResourceBundles let you create a separate source file for each locale that you support in your web applications. These files can contain text or other objects, such as images, that are specific to each locale.
ResourceBundles are an abstract class in the java.util package and must be implemented as one of the following subclasses:
If your web application requires mostly localized text information, then it is easiest to use property files (required by PropertyResourceBundle) rather than class files (required by ListResourceBundles) to store your data.
JRun uses the following conventions to determine which resource bundle to fetch based on the filename:
ClassName_languagecode_COUNTRYCODE.class
ClassName_languagecode_COUNTRYCODE.properties
The languagecode is mandatory except for the default system locale, such as en. The COUNTRYCODE is optional.
When you invoke the getBundle method with the locale, JRun fetches the proper resource class or file automatically. For example, if the locale is set to Japanese, JRun fetches MyResources_ja.class or MyResources_ja.properties.
To use resource bundles in your web applications, you provide the client locale to the ResourceBundle.getBundle method. Then you invoke the appropriate methods on the resource bundle, as the following example shows:
...
ResourceBundle bundle = ResourceBundle.getBundle("Resources",request.getLocale());
<html>
<head><title><%= bundle.getString("title") %></title></head>
��<body>
��<%-- Display all the contents based on ResourceBundle --%>
��<h2><%= bundle.getString("hello_message") %></h2>
��</body>
</html>
...
The contents of the resource bundle properties file are as follows:
title=Morning Greeting
hello_message=Good Morning
For an example, see SampleJDBCLoginModule in the /samples/SERVER-INF/lib/jrun/samples/security directory.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/jrun/4/Programmers_Guide/i10n8.htm