Struts Internationalization (I18N)

Problem Statement:

We require to achieve internationalization using Struts 1.x

We have a layout setup for our application as header footer and content and few other tiles..
There is a select box in the header JSP wherein the user is allowed to select a locale – English, or Spanish
Based on the selection, the labels/data in the content tile should change to the corresponding locale.
Ie., the labels in the content tile should be retried from the corresponding properties file as selected by the user.

On select of a locale the entire page can be submitted and loaded with labels corresponding to the selected locale.

Solution:

This can be achieved by using setLocale() method of struts Action class. What you can do is that on selection of language select box, an action can be called which will set the users selected language (locale) in session or in cookies.

And in all the other action classes you can add:

Locale locale=new Locale(LOCALE_FROM_SESSION_OR_COOKIE);
setLocale(request, locale);

For more information, you can refer following links:
http://www.roseindia.net/struts/strutsinternationalization.shtml
http://www.allapplabs.com/struts/struts_internationalization.htm

Get our Articles via Email. Enter your email address.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *