Introduction to Internationalization and Localization of ADF Faces Pages

21-4 Web User Interface Developers Guide for Oracle Application Development Framework Figure 21–2 Select Text Resource Dialog ■ From the text input window, select Expression Builder to launch the Expression Builder dialog. The dialog can also be accessed from the Property Inspector by clicking the icon to the right of a translatable property and selecting Expression Builder . ■ In the Property Inspector, enter a valid expression language string for a translatable property.

21.2.1 How to Set Resource Bundle Options

After you have created a project, you can set resource bundle options in the Project Properties dialog. To set resource bundle options for a project: 1. In the Application Navigator, double-click the project.

2. In the Project Properties dialog, select Resource Bundle to display the resource

bundle options, as shown in Figure 21–3 . Note: JDeveloper only writes strings to a resource bundle that you enter using one of the previously-listed methods. Internationalizing and Localizing Pages 21-5 Figure 21–3 Project Properties Resource Bundle dialog

3. If you want JDeveloper to automatically generate a default resource file, select

Automatically Synchronize Bundle .

4. Select one of the following resource bundle file options:

■ One Bundle Per Project - configured in a file named ProjectName.properties. ■ One Bundle Per Page - configured in a file named PageName.properties. ■ Multiple Shared Bundles .

5. Select the resource bundle type from the dropdown list:

■ XML Localization Interchange File Format XLIFF Bundle ■ List Resource Bundle ■ Properties Bundle 6. Click OK.

21.2.2 What Happens When You Set Resource Bundle Options

JDeveloper generates one or more resource bundles of a particular type based on the selections that you make in the resource bundle options part of the Project Properties dialog, as illustrated in Figure 21–3 . It generates a resource bundle the first time that you invoke the Select Text Resource dialog illustrated in Figure 21–2 . Assume, for example, that you select the One Bundle Per Project checkbox and the List Resource Bundle value from the Resource Bundle Type dropdown list. The first time that you invoke the Select Text Resource dialog, JDeveloper generates one resource bundle for the project. The generated resource bundle is a Java class named after the default project bundle name in the Project Properties dialog for example, ViewControllerBundle.java. JDeveloper generates a resource bundle as an .xlf file if you select the XML Localization Interchange File Format XLIFF Bundle option and a .properties file if you select the Properties Bundle option. 21-6 Web User Interface Developers Guide for Oracle Application Development Framework By default, JDeveloper creates the generated resource bundle in the view subdirectory of the project’s Application Sources directory.

21.2.3 How to Create an Entry in a JDeveloper-Generated Resource Bundle

JDeveloper generates one or more resource bundles based on the values you select in the resource bundle options part of the Project Properties dialog. It generates a resource bundle the first time that you invoke the Select Text Resource dialog from a component property in the Property Inspector. JDeveloper writes key-value pairs to the resource bundle based on the values that you enter in the Select Text Resource dialog. It also allows you to select an existing key-value pair from a resource bundle to render a runtime display value for a component. To create an entry in the resource bundle generated by JDeveloper: 1. In the JSF page, select the component for which you want to write a runtime value. For example, select an af:inputText component.

2. In the Property Inspector, use a property’s dropdown list to select Select Text

Resource to create a new entry in the resource bundle. The Select Text Resource entry in the dropdown list only appears for properties that support text resources. For example, the Label property of an af:inputText component.

3. Write the value that you want to appear at runtime in the Display Value input

field, as illustrated in Figure 21–2 . JDeveloper generates a value in the Key input field.

4. Optionally, write a description in the Description input field.

5. Click Save and Select.

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

JDeveloper writes the key-value pair that you define in the Select Text Resource dialog to the resource bundle. The options that you select in the resource bundle options part of the Project Properties dialog determine what type of resource bundle JDeveloper writes the key-value pair to. For more information, see Section 21.2.2, What Happens When You Set Resource Bundle Options . The component property for which you define the resource bundle entry uses an EL expression to retrieve the value from the resource bundle at runtime. For example, an af:inputText component’s Label property may reference an EL expression similar to the following: {viewcontrollerBundle.NAME} where viewcontrollerBundle references the resource bundle and NAME is the key for the runtime value. Note: JDeveloper displays a matching text resource in the Matching Text Resource field if a text resource exists that matches the value you entered in the Display Value input field exists.