David Mossakowski wrote:

> Craig, thanks for your previous help on this.  I took most
> of your advice.
>
> Now for part 2.  This is the most annoying path problem I've
> ever had,
>
> I have  mycompany.BundleManager managing LanguageResources
> which are extending ListResourceBundle
>
> BundleManager tries to do:
>
> ResourceBundle.getBundle("mycompany.resources.LanguageResources",locale);
>
> but it does not work.
>

Are your individual resource bundle classes named as described in the
ResourceBundle API documentation?  For example, the class for British English
would be named

    mycompany.resources.LanguageResources_en_GB

which should be in the same place in the directory hierarchy as any other class
in the mycompany.resources package would be.  Using your naming, that would be
directory "blah/classes/mycompany/resources").

>
> Even when I remove package information from
> LanguageResources and put them in root of where all classes
> reside (blah/classes/) and try:
>     ResourceBundle.getBundle("LanguageResources",locale);
> // without the package name
> it still does not work.
>

That should work, as long as you name your classes as described above.

>
> BUT if I create LanguageResources.properties (text files)
> and put them in the root of where these classes reside
> (again in blah/classes/) and do:
>     ResourceBundle.getBundle("LanguageResources",locale);
> // without the package name
> it works fine.
>
> Could someone please let me know what can/should go where
> and why?
>

You can use package names on property resource bundles as well -- the
properties files would go the same place that the class files would go.  For
example, if your locale was British English and you did this:

    ResourceBundle bundle =
ResourceBundle.getBundle("mycompany.resources.LanguageResources", locale);

this would try to load a property file at the following location:

    blah/classes/mycompany/resources/LanguageResources_en_GB.properties

>
> Also I have additional questions:
>
> 1.  How to represent special characters?  Is it enough to
> just put \u0105 instead of the character needed?  Is
> anything else needed in order for the browser to decode
> this?  Charset values?  It seems so because just saying
> "Ksi\u0105z\u0307ka" does not work. It produces "Ksi??ka".
>
> 2.  Does the servlet engine have to do any charset
> manipulation?  Does it have to be aware of what charset is
> being used?
>

If you are using a non-default character set, it does.  For example, you can
add a "; charset=xxxx" modifier to the content type when you call
response.setContentType(), and the PrintWriter you utilize will be configured
for this character set.

>
> 2.  I'm assuming the the LocaleElements are used just like
> any bundle and have to be explicitly loaded.  If there's
> more to it please let me know.
>

LocaleElement?  I don't recognize the term.

>
> 3.  How does the fallback on the default bundle happen?  Is
> it automatic when certain Locale can't be found (in
> ResourceBundle) or does it have to be caught (in
> BundleManger) and then the default bundle explicitly loaded?
>

As the resource bundles are loaded, the fallback is automatic -- If you ask for
British English and it's not there, the defaulting rules in the ResourceBundle
API documentation are loaded automatically instead.  Your bundle manager should
not have to care unless there is no default bundle either.

In my BundleManager, I also explicitly load a default resource bundle (by
calling getBundle() with no locale argument) for use in responding to
getMessage() calls that do not include a locale, or where the specified locale
is null.  But I found that I very rarely used this feature, so it could
probably be done away with.

>
> thanks,
> dave
>

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to