You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Tse <er...@netvigator.com> on 2002/12/05 09:02:35 UTC

i18n implementation

Dear all,

I am designing the framework of an enterprise application which serves 3 large groups of user. And of each group has 3 GUI language selections. I am now trying to generalize the functions so as to reuse most of the codes and deploy as a single application with different context-param, i.e. each group has its JAR. 

For the language issue, I do not want the web designer to "copy and paste" those JSP into 3 sets to make 3 distinct GUI webpages. (ie. 3 x 3 = 9 JARs)

Do you have any recommendation in producing 3 GUI languages? Do I really necessary to create 3 JARs with different web.xml to load the .properties files?

Any recommendation is welcome!

---
Eric Tse 
SCP, SCWCD

Re: i18n implementation

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 6 Dec 2002, Eric Tse wrote:

> Date: Fri, 6 Dec 2002 12:07:59 +0800
> From: Eric Tse <er...@netvigator.com>
> Reply-To: Eric Tse <er...@hp.com>
> To: Craig R. McClanahan <cr...@apache.org>
> Cc: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: i18n implementation
>
> Hi Craig,
>
> Thanks for your email! I have just tried your latest nighty build and it is
> what I want to have!! Thanks a lot!!
>
> I have one more question. Where or which setting do <bean:message
> key="index.logon"/> in index.jsp detects it is in Japanese locale? I
> observed that the Locale is set to ja when I access index.jsp and
> corresponding ApplicationResources_ja.properties is loaded. Since I need to
> make a language selection screen at index.jsp, does it mean i need to
> hardcode the English message instead of specifiying any <bean:message ..../>
> ?
>

Struts stores the user's selected Locale as a session attribute under the
key Action.LOCALE_KEY.  If there's no such attribute already, it chooses
based on the user's preferred language (which is sent in the
"Accept-Languages" HTTP header).

To create your own language chooser, simply set up a simple form with just
a select box listing the languages you support, and submit to an Action
that reads the specified selection, creates a corresponding Locale, and
stores it in the session attribute under the specified key.  This
selection will hold until the user changes it, or until the session
expires or is timed out.

> Thanks a lot.
>
> Regards,
> Eric

Craig



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


Re: i18n implementation

Posted by Eric Tse <er...@netvigator.com>.
Hi Craig,

Thanks for your email! I have just tried your latest nighty build and it is
what I want to have!! Thanks a lot!!

I have one more question. Where or which setting do <bean:message
key="index.logon"/> in index.jsp detects it is in Japanese locale? I
observed that the Locale is set to ja when I access index.jsp and
corresponding ApplicationResources_ja.properties is loaded. Since I need to
make a language selection screen at index.jsp, does it mean i need to
hardcode the English message instead of specifiying any <bean:message ..../>
?

Thanks a lot.

Regards,
Eric

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>; "Eric Tse"
<er...@hp.com>
Sent: Friday, December 06, 2002 10:54 AM
Subject: Re: i18n implementation


>
>
> > ----------
> > From: Craig R. McClanahan[SMTP:CRAIGMCC@APACHE.ORG]
> > Sent: Friday, December 06, 2002 10:54:21 AM
> > To: Struts Users Mailing List; Eric Tse
> > Subject: Re: i18n implementation
> > Auto forwarded by a Rule
> >
> >
> >
> On Thu, 5 Dec 2002, Eric Tse wrote:
>
> > Date: Thu, 5 Dec 2002 16:02:35 +0800
> > From: Eric Tse <er...@netvigator.com>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
> >      Eric Tse <er...@hp.com>
> > To: struts-user@jakarta.apache.org
> > Subject: i18n implementation
> >
> > Dear all,
> >
> > I am designing the framework of an enterprise application which serves 3
> > large groups of user. And of each group has 3 GUI language selections. I
> > am now trying to generalize the functions so as to reuse most of the
> > codes and deploy as a single application with different context-param,
> > i.e. each group has its JAR.
> >
> > For the language issue, I do not want the web designer to "copy and
> > paste" those JSP into 3 sets to make 3 distinct GUI webpages. (ie. 3 x 3
> > = 9 JARs)
> >
> > Do you have any recommendation in producing 3 GUI languages? Do I really
> > necessary to create 3 JARs with different web.xml to load the
> > .properties files?
> >
> > Any recommendation is welcome!
> >
>
> If you mean that each page of the application needs to be visible in
> multiple languages, that is what tags like <bean:message> is for.  Indeed,
> my need to do this a few years ago (but in twelve languages) was one of
> the early motivations that drove the me to create Struts.
>
> As an example of this in action, load the struts-example.war (recent
> nightly build) into your favorite server and change your browser's
> language preference to Japanese, then access the app.  Same exact pages --
> but the prompts and error messages are displayed in a different language.
>
> The example app doesn't have a "choose your language" switcher control,
> but that would be quite easy to add.  All you'd need is an Action that
> stored the corresponding Locale in the user's session under the key
> represented by the Action.LOCALE_KEY string.
>
> > ---
> > Eric Tse
> > SCP, SCWCD
>
> Craig
>
>


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


Re: i18n implementation

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 5 Dec 2002, Eric Tse wrote:

> Date: Thu, 5 Dec 2002 16:02:35 +0800
> From: Eric Tse <er...@netvigator.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
>      Eric Tse <er...@hp.com>
> To: struts-user@jakarta.apache.org
> Subject: i18n implementation
>
> Dear all,
>
> I am designing the framework of an enterprise application which serves 3
> large groups of user. And of each group has 3 GUI language selections. I
> am now trying to generalize the functions so as to reuse most of the
> codes and deploy as a single application with different context-param,
> i.e. each group has its JAR.
>
> For the language issue, I do not want the web designer to "copy and
> paste" those JSP into 3 sets to make 3 distinct GUI webpages. (ie. 3 x 3
> = 9 JARs)
>
> Do you have any recommendation in producing 3 GUI languages? Do I really
> necessary to create 3 JARs with different web.xml to load the
> .properties files?
>
> Any recommendation is welcome!
>

If you mean that each page of the application needs to be visible in
multiple languages, that is what tags like <bean:message> is for.  Indeed,
my need to do this a few years ago (but in twelve languages) was one of
the early motivations that drove the me to create Struts.

As an example of this in action, load the struts-example.war (recent
nightly build) into your favorite server and change your browser's
language preference to Japanese, then access the app.  Same exact pages --
but the prompts and error messages are displayed in a different language.

The example app doesn't have a "choose your language" switcher control,
but that would be quite easy to add.  All you'd need is an Action that
stored the corresponding Locale in the user's session under the key
represented by the Action.LOCALE_KEY string.

> ---
> Eric Tse
> SCP, SCWCD

Craig




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