ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/jrasdevrb.htm

38 lines
2.4 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Develop JRas resource bundles</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h6><a name="jrasdevrb"></a>Develop JRas resource bundles</h6>
<p>You can create resource bundles in several ways. The best and easiest way is to create a properties file that supports a PropertiesResourceBundle. This sample shows how to create such a properties file.</p>
<p>For this sample, four localizable messages are provided. The properties file is created and the key-value pairs inserted into it. All the normal properties files conventions and rules apply to this file. In addition, the creator must be aware of other restrictions imposed on the values by the Java MessageFormat class. For example, apostrophes must be &quot;escaped&quot; or they will cause a problem. Also avoid use of non-portable characters. WebSphere Application Server - Express does not support usage of extended formatting conventions that the MessageFormat class supports, such as {1, date} or {0,number, integer}.</p>
<p>Assume that the base directory for the application that uses this resource bundle is &quot;baseDir&quot; and that this directory sre not in the classpath. Assume that the properties file is stored in a subdirectory of baseDir that is not in the classpath (e.g. baseDir/subDir1/subDir2/resources). In order to allow the messages file to be resolved, the name subDir1.subDir2.resources.DefaultMessage is used to identify the PropertyResourceBundle and is passed to the message logger.</p>
<p>For this sample, the properties file is named DefaultMessages.properties.</p>
<pre>
# Contents of DefaultMessages.properties file
MSG_KEY_00=A message with no substitution parameters.
MSG_KEY_01=A message with one substitution parameter: parm1={0}
MSG_KEY_02=A message with two substitution parameters: parm1={0}, parm2 = {1}
MSG_KEY_03=A message with three parameter: parm1={0}, parm2 = {1}, parm3={2}
</pre>
<p>Once the file DefaultMessages.properties is created, the file can be sent to a translation center where the localized versions will be generated.</p>
</body>
</html>