File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Need a hint on internationalization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Need a hint on internationalization" Watch "Need a hint on internationalization" New topic

Need a hint on internationalization

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178

I want you to give me a hint on i18n regarding Struts. I do know the general mechanism with ResourceBundles where the application determines the language with the client's default locale. Unfortenately, the book I used to learn Struts has no info about a more sophicticated approach: which mechanisms does Struts provides for switching locales at runtime so the user can choose his language by himself? My first guess is that I just create a new action to achieve this, the action then uses a cookie to persist the made choice. But what exaclty has the action to do to switch the language?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You're on the right track. The Struts Action class (the superclass of your Action class) has a setLocale() method. By calling it, you can override the default behavior of struts, which is to use the browser's default locale to set the locale.

Consultant, Sima Solutions
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Thank you your answer, Merrill
Nyanas Kandhan
Ranch Hand

Joined: Jan 27, 2009
Posts: 35
For an example on Struts internationalization you can refer here.

Struts I18N using locale.
Struts Internationalization using browser settings.

Struts Developer

I agree. Here's the link:
subject: Need a hint on internationalization
It's not a secret anymore!