You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by éric spérano <er...@modesys.net> on 2001/01/16 22:41:57 UTC

i18n

Hello everyone,

i'm a new struts user and i have a question about i18n.

i did two properties files, let's say:

com.myproject.ApplicationResources.properties            (english)
com.myproject.ApplicationResources_fr.properties        (french)

in my web.xml, i set the init-param "application" to 
"com.myproject.ApplicationResources"

i load my servlet and the log says it has load my ResourceBundle 
successfully.

but now, how can i associate a specific language to a HttpSession??

as an example, i used the logon.jsp shipped with the struts example..

i set my browser (ie 5) to select French as my "favorite" language, but 
when i access the logon.jsp, it's always the english message that are 
printed..
i added a print out out request.getLocale() in my jsp and it prints the 
good locale, so my browser config is correct.

can someone please indicate me what is missing/wrong?


thanks a lot! and keep up the good work.



eric sperano
modesys informatique




Re: i18n

Posted by éric spérano <er...@modesys.net>.
oups, stupid reply to myself!

i forgot to say i'm using tomcat (embedded) with jboss on windows 2000, 
i don't know if this matters.

i'll try it with my linux install at home..


eric sperano.



éric spérano wrote:

> Hello everyone,
> 
> i'm a new struts user and i have a question about i18n.
> 
> i did two properties files, let's say:
> 
> com.myproject.ApplicationResources.properties            (english)
> com.myproject.ApplicationResources_fr.properties        (french)
> 
> in my web.xml, i set the init-param "application" to 
> "com.myproject.ApplicationResources"
> 
> i load my servlet and the log says it has load my ResourceBundle 
> successfully.
> 
> but now, how can i associate a specific language to a HttpSession??
> 
> as an example, i used the logon.jsp shipped with the struts example..
> 
> i set my browser (ie 5) to select French as my "favorite" language, 
> but when i access the logon.jsp, it's always the english message that 
> are printed..
> i added a print out out request.getLocale() in my jsp and it prints 
> the good locale, so my browser config is correct.
> 
> can someone please indicate me what is missing/wrong?
> 
> 
> thanks a lot! and keep up the good work.
> 
> 
> 
> eric sperano
> modesys informatique
> 
> 
> 
> 
> 
> 


Re: i18n

Posted by Peter Alfors <pe...@irista.com>.
We ran across the same problem a few months ago.

The ActionSerlvet sets the current locale in the session when the first
action is called.  Thereafter, the processLocale() function retrieves it
out of the session, rather than checking if the locale has changed.
We chose to over-ride the processLocale function.  If we are running in
debug mode, the locale is retrieved from the request and reset in the
session for each action.  This allows us to test language translation
much easier/faster.
However, there is another method.

IE (and I am pretty sure Netscape) store one session.  So if you have
multiple browser sessions running, they will all use the same session.
Likewise, the session will not be removed from memory unless ALL browser
sessions are closed.  This means that if you start IE with Engish as
your preferred language, then Struts sets the language in the session to
be english (after the first action is called).  You will not see your
language change (even though you changed it in the browser) until you
restart IE.  This will force the session to be closed, and a new one
started.  On the next action, the locale should be set to the new
language (French).

I hope this helps,

    Pete

Re: i18n

Posted by Ted Husted <ne...@husted.com>.
I believe there's a gotcha where the default locale is set according to
the server's default, rather than the user's browser settings.

Here's an example of adding a drop-down box to select a language 

<
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg00999.html
 >

and another i18n example

<
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg00974.html
 >


*********** REPLY SEPARATOR  ***********

On 1/16/2001 at 4:41 PM �ric sp�rano wrote:

Hello everyone,

i'm a new struts user and i have a question about i18n.

i did two properties files, let's say:

com.myproject.ApplicationResources.properties            (english)
com.myproject.ApplicationResources_fr.properties        (french)

in my web.xml, i set the init-param "application" to 
"com.myproject.ApplicationResources"

i load my servlet and the log says it has load my ResourceBundle 
successfully.

but now, how can i associate a specific language to a HttpSession??

as an example, i used the logon.jsp shipped with the struts example..

i set my browser (ie 5) to select French as my "favorite" language, but

when i access the logon.jsp, it's always the english message that are 
printed..
i added a print out out request.getLocale() in my jsp and it prints the

good locale, so my browser config is correct.

can someone please indicate me what is missing/wrong?


thanks a lot! and keep up the good work.



eric sperano
modesys informatique




RE: i18n

Posted by Denis Hanson <de...@mediaone.net>.
Hello Eric,

To set the locale that struts uses, I put this code at the top of my
index.jsp:


<%
   Locale locale = request.getLocale();
   session.setAttribute(Action.LOCALE_KEY, locale);
%>


Denis Hanson




-----Original Message-----
From: eric sperano [mailto:eric.sperano@modesys.net]
Sent: Tuesday, January 16, 2001 4:42 PM
To: struts-user@jakarta.apache.org
Subject: i18n


Hello everyone,

i'm a new struts user and i have a question about i18n.

i did two properties files, let's say:

com.myproject.ApplicationResources.properties            (english)
com.myproject.ApplicationResources_fr.properties        (french)

in my web.xml, i set the init-param "application" to
"com.myproject.ApplicationResources"

i load my servlet and the log says it has load my ResourceBundle
successfully.

but now, how can i associate a specific language to a HttpSession??

as an example, i used the logon.jsp shipped with the struts example..

i set my browser (ie 5) to select French as my "favorite" language, but
when i access the logon.jsp, it's always the english message that are
printed..
i added a print out out request.getLocale() in my jsp and it prints the
good locale, so my browser config is correct.

can someone please indicate me what is missing/wrong?


thanks a lot! and keep up the good work.



eric sperano
modesys informatique