You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Juan Alvarado (Struts List)" <ju...@manduca.com> on 2002/06/28 19:10:48 UTC
Question about how to deal with locales
I have a page that a user can click on to decide what language he/she wants
to view an application with. My action is as follows:
//check for a language chose if the parameter exists
if( language != null ){
if( "spanish".equals(language) ){
locale = new Locale( "ES", "VE");
}
if( "english".equals(language) ){
locale = new Locale( "EN", "US");
}
}
session.setAttribute("ADMINISTRATION_RESOURCES", locale);
return mapping.findForward("success");
So at this point I am assumming there is a session level Locale object
called "ADMINISTRATION_RESOURCES".
In my jsp I am doing the following:
<bean:message key='admin.prompt.builddailyindex' bundle='ADMIN_RESOURCES'/>
The bundle ADMIN_RESOURCES is defined in my struts-config as:
<message-resources key="ADMIN_RESOURCES" parameter="AdminResources"
null="false"/>
In my WEB-INF/classes folder I have AdminResources.properties and
AdminResources_ES_VE.properties.
My problem is that the JSP always uses the US locale and I can't get it to
display spanish messages.
I think it has to do with how my definition is set up in the struts-config.
Any help with this is greatly appreciated.
Thanks in advance
**********************************************
Juan Alvarado
Internet Developer -- Manduca Management
(786)552-0504
jalvarado@manduca.com
AOL Instant Messenger: juan2000@aol.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Question about how to deal with locales
Posted by "Juan Alvarado (Struts List)" <ju...@manduca.com>.
I don't have a problem using the Action.LOCALE_KEY, but my problem is on the
JSP:
<bean:message key='admin.prompt.builddailyindex' bundle='ADMIN_RESOURCES'/>
Since I have different MessageResources for specific tasks, in my JSP I want
the <bean:message... tag to load the correct message resources based on the
locale. The problem is that no matter what the locale is, the tag always
loads the EN_US locale. I am almost sure it is because in my struts-config I
have the following definition:
<message-resources key="ADMIN_RESOURCES" parameter="AdminResources"
null="false"/>
and the tag always grabs AdminResources.properties.
So what I need to know is if there is a mechanism within struts that based
on the bundle parameter inside the tag, it will go out and grab the correct
properties file for the current locale.
Thanks
**********************************************
Juan Alvarado
Internet Developer -- Manduca Management
(786)552-0504
jalvarado@manduca.com
AOL Instant Messenger: juan2000@aol.com
-----Original Message-----
From: Barbara Post [mailto:babs33@ifrance.com]
Sent: Friday, June 28, 2002 1:22 PM
To: Struts Users Mailing List; juan_alvarado@manduca.com
Subject: Re: Question about how to deal with locales
dumb question : why don't you use :
session.setAttribute(Action.LOCALE_KEY, theLocaleIWant); ?
so every action will use the locale you want :-)
but maybe you don't want this ?
Babs
----- Original Message -----
From: Juan Alvarado (Struts List) <ju...@manduca.com>
To: Struts <st...@jakarta.apache.org>
Sent: Friday, June 28, 2002 7:10 PM
Subject: Question about how to deal with locales
> I have a page that a user can click on to decide what language he/she
wants
> to view an application with. My action is as follows:
>
> file://check for a language chose if the parameter exists
> if( language != null ){
> if( "spanish".equals(language) ){
> locale = new Locale( "ES", "VE");
> }
> if( "english".equals(language) ){
> locale = new Locale( "EN", "US");
> }
> }
> session.setAttribute("ADMINISTRATION_RESOURCES", locale);
> return mapping.findForward("success");
>
> So at this point I am assumming there is a session level Locale object
> called "ADMINISTRATION_RESOURCES".
>
> In my jsp I am doing the following:
> <bean:message key='admin.prompt.builddailyindex'
bundle='ADMIN_RESOURCES'/>
>
> The bundle ADMIN_RESOURCES is defined in my struts-config as:
> <message-resources key="ADMIN_RESOURCES" parameter="AdminResources"
> null="false"/>
>
> In my WEB-INF/classes folder I have AdminResources.properties and
> AdminResources_ES_VE.properties.
>
> My problem is that the JSP always uses the US locale and I can't get it to
> display spanish messages.
>
> I think it has to do with how my definition is set up in the
struts-config.
>
> Any help with this is greatly appreciated.
>
> Thanks in advance
>
>
> **********************************************
> Juan Alvarado
> Internet Developer -- Manduca Management
> (786)552-0504
> jalvarado@manduca.com
>
> AOL Instant Messenger: juan2000@aol.com
>
>
> --
> 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>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Question about how to deal with locales
Posted by Barbara Post <ba...@ifrance.com>.
dumb question : why don't you use :
session.setAttribute(Action.LOCALE_KEY, theLocaleIWant); ?
so every action will use the locale you want :-)
but maybe you don't want this ?
Babs
----- Original Message -----
From: Juan Alvarado (Struts List) <ju...@manduca.com>
To: Struts <st...@jakarta.apache.org>
Sent: Friday, June 28, 2002 7:10 PM
Subject: Question about how to deal with locales
> I have a page that a user can click on to decide what language he/she
wants
> to view an application with. My action is as follows:
>
> file://check for a language chose if the parameter exists
> if( language != null ){
> if( "spanish".equals(language) ){
> locale = new Locale( "ES", "VE");
> }
> if( "english".equals(language) ){
> locale = new Locale( "EN", "US");
> }
> }
> session.setAttribute("ADMINISTRATION_RESOURCES", locale);
> return mapping.findForward("success");
>
> So at this point I am assumming there is a session level Locale object
> called "ADMINISTRATION_RESOURCES".
>
> In my jsp I am doing the following:
> <bean:message key='admin.prompt.builddailyindex'
bundle='ADMIN_RESOURCES'/>
>
> The bundle ADMIN_RESOURCES is defined in my struts-config as:
> <message-resources key="ADMIN_RESOURCES" parameter="AdminResources"
> null="false"/>
>
> In my WEB-INF/classes folder I have AdminResources.properties and
> AdminResources_ES_VE.properties.
>
> My problem is that the JSP always uses the US locale and I can't get it to
> display spanish messages.
>
> I think it has to do with how my definition is set up in the
struts-config.
>
> Any help with this is greatly appreciated.
>
> Thanks in advance
>
>
> **********************************************
> Juan Alvarado
> Internet Developer -- Manduca Management
> (786)552-0504
> jalvarado@manduca.com
>
> AOL Instant Messenger: juan2000@aol.com
>
>
> --
> 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>