233 total views, 6 views today

JSF Internationalization Example

JSF reads the language-specific property file automatically depends on the default language sets in the browser. We need to create a property file for each language our project is supporting. For example, if your project supports two locals, French, German and the default English locale. Click ISO 631-1CODES to find the locale for each language.

Constant.properties (Default, English Local)

Constant_fr.properties (French Local)

Constant_de.properties (GERNAL local)

 

JSF Internationationalization Example 

 

As you see below, I have two property files in my project. One is French and other is default, English, 

 

JSF_Localization JSF Internationalization Example

 

The file constants_fr.properties has  

 

The fie constants.properties has 

 

 

I registered both the locale specific property files in faces-config.xml file 

 

 

Belos is my Managed Bean class, session scoped.  The changeLanguage method changes the locale over the session

 

 

Below is the JSF page; The outputText change the message based on the button clicked.  

 

 

My browser default language is English so the page loads with Hello

 

100117_2354_JSFInternat1 JSF Internationalization Example

 

The message changed after the button French is clicked. The button calls the changeLanguage method in USser bean and changes the locale in the session. 

 

100117_2354_JSFInternat2 JSF Internationalization Example

 

Download JSF Internationalization Project : JSF Internationalization Example

govindan JSF Internationalization Example
Connect me

Govind

Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply šŸ™‚
govindan JSF Internationalization Example
Connect me
By | 2017-10-01T19:29:10+00:00 October 1st, 2017|Categories: JSF|Tags: , , , , |0 Comments
Like us on Facebook.
Connect!