You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Vaddiyar, Raghuramudu" <Ra...@sisclear.com> on 2002/03/26 10:23:33 UTC

tag

Hi All,

I am new to struts and am developing an application which has to support
internationalization. When i saw the documentation of struts, it says that
the <bean:message> tag can render internationlized messages by overriding
the "bundle" and "locale" attrobutes of the <bean:message> tag. But i dont
know
what values has to be set for this attributes??.

Can anyone explain what does this "bundle" and "locale" attributes represent
and
what values has to be set so that it renders internationalized messages???

Thanks in advance.

Raghu
SIS

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: tag

Posted by Ivan Siviero <iv...@concept.it>.
When you want to display an internationalized message on a web page you can
write the tag

<bean:message key="message.key">

In the ApplicationResources.properties you specify the following line

message.key=this is my message

If you want a German translation you define an
ApplicationResources_de.properties which contains the following

message.key=this is my german message

The <bean:message> tag normally looks for a locale in the session under the
attribute (Action.LOCALE_KEY).
So to switch the language you just have to set your locale with the
following line:

request.getSession().setAttribute(Action.LOCALE_KEY, yourLocale);
you can either do the following when implementing the perform() method of an
action

setLocale(request, locale);

if you want to use another locale from the bean message tag you just have to
specify this with the locale property:

<bean:message key="message.key" locale="localeBean"/>

the above line supposes a locale object stored in the session under the key
"localeBean" so the <bean:message> will look for a key "message.key" under
the ApplicationResources.properties matching that locale.

Now let's suppose you want to specify your localized message into a
different .properties file.
You can do this with the bundle parameter.

<bean:message bundle="myBundle" key="message.key" locale="localeBean"/>

will look for the key "message.key" in the bundle stored under the bean
named "myBundle" for a locale stored under the bean named "localeBean".
The bean named "myBundle" is a MessageResource object.
you have to add it to the ServletContext with the following lines (let's
suppose you are coding a startup Servlet):
MessageResources myResources =
MessageResourcesFactory.createFactory().createResources("resourceFilename");

this.getServletContext().setAttribute("myBundle", myResources );

This works quite fine for me.
Hope this helps
Ivan.

----- Original Message -----
From: "Vaddiyar, Raghuramudu" <Ra...@sisclear.com>
To: "Struts (E-mail)" <st...@jakarta.apache.org>
Sent: Tuesday, March 26, 2002 11:23 AM
Subject: <bean:message> tag


> Hi All,
>
> I am new to struts and am developing an application which has to support
> internationalization. When i saw the documentation of struts, it says that
> the <bean:message> tag can render internationlized messages by overriding
> the "bundle" and "locale" attrobutes of the <bean:message> tag. But i dont
> know
> what values has to be set for this attributes??.
>
> Can anyone explain what does this "bundle" and "locale" attributes
represent
> and
> what values has to be set so that it renders internationalized messages???
>
> Thanks in advance.
>
> Raghu
> SIS
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>