You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by None None <fz...@hotmail.com> on 2004/05/13 17:24:07 UTC
Language resource bundles problem
Hello all. I posted this question a little while ago as a reply to another
thread, but I figured the question might be lost there...
I'm trying to get multiple language support to work. I have created two
files, ofmResources.properties and ofmResources_de.properties and stored
them in WEB-INF/classes.
In web.xml I have:
...
<init-param>
<param-name>application</param-name>
<param-value>ofmResources</param-value>
</init-param>
...
...as an init parameter of ActionServlet. Then, in a particular action I
need to return a message to the view, so I do this:
MessageResources mr = getResources(request);
myActionForm.setMessage(mr.getMessage("messages.deleteFailed"));
Now, this works just fine. My message is displayed as a result of the
onLoad event of my page via a simple JavaScript alert box. Very cool.
However, if I want to display the message from the German resource file, I
can't get it to work. I thought all I had to do was this:
myActionForm.setMessage(mr.getMessage("de", "messages.deleteFailed"));
...but it always seems to return null. I am expecting that the framework
will, in simplest terms, just append _de to the "ofmResources" value of the
application init param, and therefore get the messages.deleteFailed value
out of that file rather than the default ofmResources.properties file.
Am I nuts or should it not work that way? If I'm nuts (or nutier than
normal :) ), then how does one get this to work? If I'm not nuts, any ideas
why what I'm doing doesn't work? Thanks all!
_________________________________________________________________
Best Restaurant Giveaway Ever! Vote for your favorites for a chance to win
$1 million! http://local.msn.com/special/giveaway.asp
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Language resource bundles problem
Posted by Harjot Narula <ha...@induslogic.com>.
Hi
I think you need to mention something like this in web.xml
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
and in struts-config.xml you need to have this
<message-resources parameter="ofmResources"/>
<message-resources key="de" parameter="ofmResources_de"/>
you can use this in JSP as
<bean:message bundle="de" key="messages.deleteFailed" />
This will also work probably
myActionForm.setMessage(mr.getMessage("de", "messages.deleteFailed"));
Correct me if I am wrong
Harjot
----- Original Message -----
From: "None None" <fz...@hotmail.com>
To: <us...@struts.apache.org>
Sent: Thursday, May 13, 2004 8:54 PM
Subject: Language resource bundles problem
> Hello all. I posted this question a little while ago as a reply to
another
> thread, but I figured the question might be lost there...
>
> I'm trying to get multiple language support to work. I have created two
> files, ofmResources.properties and ofmResources_de.properties and stored
> them in WEB-INF/classes.
>
> In web.xml I have:
>
> ...
> <init-param>
> <param-name>application</param-name>
> <param-value>ofmResources</param-value>
> </init-param>
> ...
>
> ...as an init parameter of ActionServlet. Then, in a particular action I
> need to return a message to the view, so I do this:
>
> MessageResources mr = getResources(request);
> myActionForm.setMessage(mr.getMessage("messages.deleteFailed"));
>
> Now, this works just fine. My message is displayed as a result of the
> onLoad event of my page via a simple JavaScript alert box. Very cool.
>
> However, if I want to display the message from the German resource file, I
> can't get it to work. I thought all I had to do was this:
>
> myActionForm.setMessage(mr.getMessage("de", "messages.deleteFailed"));
>
> ...but it always seems to return null. I am expecting that the framework
> will, in simplest terms, just append _de to the "ofmResources" value of
the
> application init param, and therefore get the messages.deleteFailed value
> out of that file rather than the default ofmResources.properties file.
>
> Am I nuts or should it not work that way? If I'm nuts (or nutier than
> normal :) ), then how does one get this to work? If I'm not nuts, any
ideas
> why what I'm doing doesn't work? Thanks all!
>
> _________________________________________________________________
> Best Restaurant Giveaway Ever! Vote for your favorites for a chance to win
> $1 million! http://local.msn.com/special/giveaway.asp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org