How to Use Resource Bundles in Your Application

Internationalizing and Localizing Pages 21-17 ... import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice; public class ChangeLocale { ... ... private RichSelectOneChoice soc1; ... ... ... public void setD2RichDocument d2 { this.d2 = d2; } ... public void setSoc1RichSelectOneChoice soc1 { this.soc1 = soc1; } public RichSelectOneChoice getSoc1 { return soc1; } public void setSi1RichSelectItem si1 { this.si1 = si1; } ... } 21.4.3 What Happens at Runtime When an End User Specifies a Locale At runtime, an end user invokes the command component you configured to change the locale of the application. The backing bean stores the updated locale information. Pages where the locale attribute of the f:view tag reference the backing bean render using the locale specified by the end user. The locale specified by the end user must be registered with your application. For more information about specifying a locale and associated resource bundles, see Section 21.3.3, How to Register Locales and Resource Bundles in Your Application . 21.5 Configuring Optional ADF Faces Localization Properties Along with providing text translation, ADF Faces also automatically provides other types of translation, such as text direction and currency codes. The application will automatically be displayed appropriately, based on the user’s selected locale. However, you can also manually set the following localization settings for an application in the trinidad-config.xml file: ■ currency-code: Defines the default ISO 4217 currency code used by oracle.adf.view.faces.converter.NumberConverter to format currency fields that do not specify a currency code in their own converter. ■ number-grouping-separator: Defines the separator used for groups of numbers for example, a comma. ADF Faces automatically derives the separator 21-18 Web User Interface Developers Guide for Oracle Application Development Framework from the current locale, but you can override this default by specifying a value in this element. If set, this value is used by oracle.adf.view.faces.converter.NumberConverter while it parses and formats. ■ decimal-separator: Defines the separator used for the decimal point for example, a period or a comma. ADF Faces automatically derives the separator from the current locale, but you can override this default by specifying a value in this element. If set, this value is used by oracle.adf.view.faces.converter.NumberConverter while it parses and formats. ■ right-to-left: Defines the direction in which text appears in a page. ADF Faces automatically derives the rendering direction from the current locale, but you can explicitly set the default page rendering direction by using the values true or false. ■ time-zone: Defines the time zone appropriate to the selected locale. ADF Faces automatically uses the time zone used by the client browser. This value is used by oracle.adf.view.faces.converter.DateTimeConverter when it converts String to Date. ■ formatting-locale: Defines the date and number format appropriate to the selected locale. ADF Faces and Trinidad, will by default, format dates and numbers in the same locale used for localized text. If you want dates and numbers formatted in a different locale, you can use an IANA-formatted locale for example, ja, fr-CA. The contents of this element can also be an EL expression pointing at an IANA string or a java.util.Locale object.

21.5.1 How to Configure Optional Localization Properties

You can configure optional localization properties by entering elements in the trinidad-config.xml file. To configure optional localization properties: 1. Open the trinidad-config.xml file. The file is located in the View_ ProjectWEB-INF directory. 2. From the Component Palette, drag the element you wish to add to the file into the Structure window. An empty element is added to the page. 3. Enter the desired value. Example 21–11 shows a sample trinidad-config.xml file with all the optional localization elements set. Example 21–11 Configuring Currency Code and Separators for Numbers and Decimal Point -- Set the currency code to US dollars. -- currency-codeUSDcurrency-code -- Set the number grouping separator to period for German -- -- and comma for all other languages -- number-grouping-separator {view.locale.language==de ? . : ,} number-grouping-separator -- Set the decimal separator to comma for German -- -- and period for all other languages --