I think your solution below should be a last resort - I would look first at
trying to cure the performance problem you have and only after lots of
effort consider the route you're proposing.

How many messages do you have in each of your four properties files?

Is the performance problem just the first time you access a message for a
given locale? Does it improve subsequent times you run your jsp for a
locale?

MessageResources stores all messages in a single HashMap using a combination
of the locale and message key. The first time a locale is used it attempts
to load the messages for that locale.

1) If the performance problem is just the first time perhaps you could put a
"getMessage(locale, key)" call for each of your four locales when
ActionServlet starts up so that all messages for your four locales are
loaded ready.

2) Perhaps the HaspMap is getting too large with all your messages for your
four locales. I have had a quick peek in Struts source and its been designed
so that if you want you can create your own implementation of
MessageResources. You could try and implement a storage mechanism which
suits your situation better or is more efficient than the Struts one.

Struts provides the PropertyMessageResources and
PropertyMessageResourcesFactory classes as concrete implementations of
MessageResources and MessageResourcesFactory and these are the default
classes it uses. To create your own you just need to provide your own
concrete implementations of these classes and have a "factory" parameter in
your web.xml file for the ActionServlet configuration.

Niall

P.S. Having a tag look up a key value is never going to be as efficient as
what your proposing, which is effectively hard coding your literals in html,
but it shouldn't be as slow as what you say.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 27 April 2001 23:34
> To: [EMAIL PROTECTED]
> Subject: Re: i18n...
>
>
> I hate to keep asking the same question but I haven't gotten any
> repsonse yet.
>
> One thought I have had is do do something like:
>
> if(en)
> {
>   <jsp:include file="english.jsp"/>
> }
> else (fr)
> {
>   <jsp:include file="french.jsp"/>
> }
> etc...
>
> What would be the performance drawbacks of something like this?
>
>
> ------------------
> Jason Smith
> [EMAIL PROTECTED]
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> Date: Friday, April 27, 2001 12:53 pm
> Subject: i18n...
>
> > I have a couple of questions.
> >
> > I had a JSP in which I had approximately 40 bean:message tags for
> > i18n.
> > This page was taking 15 seconds to load.  If I had two requests
> > for the
> > page at the same time it would take 45 to 60 seconds.  Obviously
> > this is
> > not acceptable.  When I replaced the bean:message tags with the
> > text,
> > the response time goes to a respectable 3 to 5 seconds with
> > multiple
> > hits.  Therefore, I have to come up with another method of
> > internationalization.
> >
> > I am new to this so I am looking for suggestions.  I have to
> > support 4
> > languages.  My current thought is to detect the browser's settings
> > and
> > forward the request to the appropriate JSP that is specific to the
> > language settings.  I'm not sure exactly where this should be
> > done.  I
> > would like it to be dynamic so that I can reuse FORM and ACTION
> > beans
> > for each related page.
> >
> > Again, any suggestions would be appreciated.
> >
> > ------------------
> > Jason Smith
> > [EMAIL PROTECTED]
> >
> >
>
>

Reply via email to