What Happens When You Set Resource Bundle Options

21-8 Web User Interface Developers Guide for Oracle Application Development Framework

21.3.1 How to Define the Base Resource Bundle

You must create a base resource bundle that contains all the text strings that are not part of the components themselves. This bundle should be in the default language of the application. You can create a resource bundle as a property file, as an XLIFF file, or as a Java class. After a resource bundle file has been created, you can edit the file using the Edit Resource Bundles dialog. To create a resource bundle as a property file or an XLIFF file: 1. In JDeveloper, create a new file. ■ In the Application Navigator, right-click where you want the file to be placed and choose New from the context menu to open the New Gallery. ■ In the Categories tree, select General, and in the Items list, select File. Click OK . ■ In the Create File dialog, enter a name for the file using the convention name_lang.properties for the using the properties file or name_ lang.xlf for using the XLIFF file, where the _lang suffix is provided for translated files, as in _de for German, and omitted for the base language. 2. Enter the content for the file. You can enter the content manually by entering the key-value pairs. You can use the Edit Resource Bundle dialog to enter the key-value pairs, as described in Section 21.3.2, How to Edit a Resource Bundle File . ■ If you are creating a property file, create a key and value for each string of static text for this bundle. The key is a unique identifier for the string. The value is the string of text in the language for the bundle. 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. Tip: The getBundle method used to load the bundle looks for the default locale classes before it returns the base class bundle. If it fails to find a match, it throws a MissingResourceException error. A base class with no suffixes should always exist as a default. Otherwise, it may not find a match and the exception is thrown. Note: If you are creating a localized version of the base resource bundle, save the file to the same directory as the base file. 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 file. For example, the Italian version of the UIResources bundle is UIResources_it.properties. 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. 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.