Thursday, June 11, 2015

Internationalization in ADF

In this post, we will see how to configure an ADF application so that the application can be used in a variety of locales and international user environments.

Create a new application InternationalizationApp.







 Ensure that encoding preference is set to 'UTF-8'
Tools>Preferences>Environment>Encoding.




To simplify the process of creating text resources for text you add to ADF Faces components, JDeveloper supports automatic resource bundle synchronization for any translatable string in the visual editor. When you edit components directly in the visual editor or in the Properties window, text resources are automatically created in the base resource bundle.
In the View Controller project properties, enable Automatically Synchronize Bundle option .





Create a new page with two input texts and a button.

Jdeveloper generates a resource bundle the first time that you invoke the Select Text Resource dialog from a component property in the Properties window. It writes key-value pairs to the resource bundle based on the values that you enter in the Select Text Resource dialog.
Automatically a properties file is created in View Controller project .


I will create properties file for Hindi and French languages to show how the labels would change based on browse locale.
I have used google translator to translate english labels into Hindi and French languages.

Hindi resource bundle (ViewControllerBundle_hi.properties).


French resource bundle (ViewControllerBundle_hi.properties). 



Register the resource bundles in faces-config.xml file with default locale as english
Faces-Config>Overview>Application>Resource Bundle
 


Run the page.



Change the browser locale to Hindi.




Refresh the page to see the changes.

Change the browse locale to French.



Refresh the page to see the changes.


Hope this post is helpful :)