How to Create an Entry in a JDeveloper-Generated Resource Bundle What Happens When You Create an Entry in a JDeveloper-Generated Resource Bundle

Internationalizing and Localizing Pages 21-9 For example, the key and the value for the title of the myDemo page is: myDemo.pageTitle=My Purchase Requests ■ If you are creating an XLIFF file, enter the proper tags for each key-value pair. For example: ?xml version=1.0 encoding=windows-1252 ? xliff version=1.1 xmlns=urn:oasis:names:tc:xliff:document:1.1 file source-language=en original=myResources datatype=xml body trans-unit id=NAME sourceNamesource target noteName of employeenote trans-unit trans-unit id=HOME_ADDRESS sourceHome Addresssource target noteAdress of employeenote trans-unit trans-unit id=OFFICE_ADDRESS sourceOffice Addresssource target noteOffice building note trans-unit body file xliff

3. After you have entered all the values, click OK.

To create a resource bundle as a Java class: 1. In JDeveloper, create a new Java class: ■ In the Application Navigator, right-click where you want the file to be placed and choose New to open the New Gallery. ■ In the Categories tree, select General, and in the Items list, select Java Class. Click OK. ■ In the Create Java Class dialog, enter a name and package for the class. The class must extend java.util.ListResourceBundle. Note: All non-ASCII characters must be UNICODE-escaped or the encoding must be explicitly specified when compiling, for example: javac -encoding ISO8859_5 UIResources_it.java Note: If you are creating a localized version of the base resource bundle, it must reside in the same directory as the base file. 21-10 Web User Interface Developers Guide for Oracle Application Development Framework 2. Implement the getContents method, which simply returns an array of key-value pairs. Create the array of keys for the bundle with the appropriate values. Or use the Edit Resource Bundles dialog to automatically generate the code, as described in Section 21.3.2, How to Edit a Resource Bundle File . Example 21–5 shows a base resource bundle Java class. Example 21–5 Base Resource Bundle Java Class package sample; import java.util.ListResourceBundle; public class MyResources extends ListResourceBundle { public Object[][] getContents { return contents; } static final Object[][] contents { {button_Search, Search}, {button_Reset, Reset}, }; }

21.3.2 How to Edit a Resource Bundle File

After you have created a resource bundle property file, XLIFF file, or Java class file, you can edit it using the source editor. To edit a resource bundle after it has been created: 1. In JDeveloper, choose Application Edit Resource Bundles from the main menu. 2. In the Edit Resource Bundles dialog, select the resource bundle file you want to edit from the Resource Bundle dropdown list, as shown in Figure 21–4 , or click the Search icon to launch the Select Resource Bundle dialog. Note: If you are creating a localized version of a base resource bundle, you must append the ISO 639 lowercase language code to the name of the class. For example, the Italian version of the UIResources bundle might be UIResources_it.java. You can add the ISO 3166 uppercase country code for example it_CH, for Switzerland if one language is used by more than one country. You can also add an optional nonstandard variant for example, to provide platform or region information. If you are creating the base resource bundle, do not append any codes. Note: Keys must be String objects. If you are creating a localized version of the base resource bundle, any key not found in this version will inherit the values from the base class.