Im ade a mistake in my previous message the correct code is :
System.out.println(request.getLocale());
if(request.getLocale()!=null)
  System.out.println(request.getLocale().getLanguage());
MessageResources lang=this.getResources(request); //instead of MessageResources lang=(MessageResources)request.getSession().getAttribute(Globals.MESSAGE_KEY);

I have a look at struts action code and methods

protected MessageResources getResources(HttpServletRequest request)

and

protected MessageResources getResources( HttpServletRequest request, String key) {

are very different :
The first one returns : return ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));
and the second one do :

protected MessageResources getResources(
       HttpServletRequest request,
       String key) {

       // Identify the current module
       ServletContext context = getServlet().getServletContext();
       ModuleConfig moduleConfig =
           ModuleUtils.getInstance().getModuleConfig(request, context);

       // Return the requested message resources instance
       return (MessageResources) context.getAttribute(
           key + moduleConfig.getPrefix());

   }


Xavier Vanderstukken wrote:

Hello,

All my site supports i18n mechanism correctly, using Struts LocaleAction and bean taglib. However when I try to access messageresource in my action the language of the messageresource is allways the default one (in my case en_us).


System.out.println(request.getLocale());
if(request.getLocale()!=null)
   System.out.println(request.getLocale().getLanguage());
MessageResources lang=(MessageResources)request.getSession().getAttribute(Globals.MESSAGE_KEY);

--> Output :
en_US
en

and : System.out.println(lang.getMessage("mail.title")); output english message instead of current locale one.

Am I doing something wrong to read the messageresource in the action classes, because i18n works correctly in my jsp pages?
Is it due to the use of the Struts LocaleAction?



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to