harry
harry

Reputation: 89

Struts internationalization

I'm working on one portal product. I'm facing problem in making it internationalized. I'm using following code

Locale locale = new Locale(languageHashMap.get(preferredLanguageId));
ActionContext.getContext().setLocale(locale);
session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, locale);

for setting the locale.

For one time it is working fine but when I change the langauge again the change the language again, the change is not reflecting in all the pages. Still get the changes made by the last language only. Any help will be appreciated

Upvotes: 1

Views: 231

Answers (2)

JAgan R
JAgan R

Reputation: 1

its working fine....

Locale locale = new Locale(languageHashMap.get(preferredLanguageId)); ActionContext.getContext().setLocale(locale); session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, locale);

Upvotes: 0

Ratika
Ratika

Reputation: 26

I guess the locale is not setting properly. Try out the following code :

create one map

private static Map<Locale, ResourceBundle> messageBundles = new Hashtable<Locale, ResourceBundle>();

and then use the following:

Locale requestLocale = ActionContext.getContext().getLocale();
ResourceBundle rb = messageBundles.get(requestLocale);

and then put that resource bundle in the request scope.

Upvotes: 1

Related Questions