kdlitwak wrote:
> I asked this a few days ago and will try again. I need to know how to
> inernationalize a JSP. The J2EE blueprints say it can be done, but
> since no one has replied to me, I'm beginning to doubt that statement.
> Thanks.
>
I deal with at least part of the internationalization problem in the Struts
framework <http://jakarta.apache.org/struts> by employing this strategy:
* I define all of the prompts and messages that are used in the
user interface using java.util.ResourceBundles (in particular,
property resource bundles, as described in the JDK docs).
* I have a utility class (MessageResources) that has a
getMessage() method that takes two arguments -- the identifier
of the message I want, and a Locale defining the language etc.
in which to display it. This class looks up the message in the
resource bundle for that Locale, as opposed to the plain old
ResourceBundle class that uses the system locale.
* When the user logs in, one of the things I store in a session is
a java.util.Locale object under a "well known" name. Usually,
in the user interface I create a way for the user to switch
languages on the fly, which is done by changing the Locale
stored here.
* In the Struts custom tag library, there is a tag <struts:message>
used to look up all the prompts. It takes as an argument a
message identifier, and uses the Locale stored in the user's
session to call the MessageResources.getMessage() method
described above.
* Every place in the UI that I present prompts and messages, I use
the <struts:message> tag to look up the corresponding text.
This approach means I still have only one copy of every page. An alternative
strategy would be to maintain a separate copy of each page in each desired
language, but this quickly becomes a maintenance nightmare as you scale up the
number of languages and/or the number of pages.
>
> Ken
>
Craig McClanahan
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00): Sun Technical Briefing
Session T06 (24-Oct 14h00-15h00): Migrating Apache JServ
Applications to Tomcat
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets