Mike Engelhart wrote:
> > You only have to load the bundle once -- I normally do this in the init()
> method of
> > a startup servlet:
> >
> > ResourceBundle rb =
> > ResourceBundle.getBundle("com.mycompany.mypackage.Resources");
> > getServletContext().setAttribute("bundleBean", rb);
>
> But then aren't you only loading one language resource of the bundle?
> Do I only need to set the parent resource to the ResourceBundle of my
> LocaleBean and the ResourceBundle class will automatically load all the
> child resource files? Sorry if these are absent minded, but I wasn't
> planning on localizing my app but when I started a small rewrite, I thought
> the time was right to waste an extra couple of days on this :-)
>
Doing it this way does indeed load the resources for only one language -- I
was addressing your question about caching rather than an a full-blown
design. You can also use a second argument to the ResourceBundle.getBundle()
method that lets you specify the Locale for which you want to grab resources,
and then store the resource bundle for each locale under a different name.
Or, you could create a wrapper class that includes a method:
String getMessage(String key, Locale locale)
to retrieve the message text from whatever resource bundle is appropriate for
the requested locale. (The wrapper class would contain the Locale-specific
resource bundles in an internal data structure, and would pick the right one
based on the values in the specified locale.)
A couple of weeks ago, I posted a fairly long message to this mailing list
describing an overall strategy for an internationalized application. You
might check the mailing list archives for a message thread "Creating
Internationalized JSP-Based Applications".
>
> thanks,
>
> Mike
Craig
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html