db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David W. Van Couvering" <David.Vancouver...@Sun.COM>
Subject Derby resource bundles and default locale
Date Sun, 23 Oct 2005 03:17:14 GMT
Hi, all.  In part of my proof-of-concept for shared code, I am working 
at making a few messages currently specific to the engine to be shared 
between the network client and engine.

The Javadoc for ResourceBundle indicates that when you look for a bundle 
it looks first for the locale specified (if any), then the default 
locale, and then for a bundle with no locale suffix.  e.g. if you say

   ResourceBundle.getBundle("org.apache.derby.loc.mymessages")

and the current locale is "ja_JP" then it will look for the following 
property files:

    mymessages_ja_JP.properties
    mymessages.properties

This is very nice, because you can have "fallback" messages in 
mymessages.properties if for whatever reason we haven't localized to the 
default locale of a given user.

But for some reason, instead of putting our fallback messages in the 
non-qualified properties file (e.g. "mymessages.properties"), we put 
them in a properties file for the "en" locale, e.g. 
"mymessages_en.properties".

Then in our code, when we look up a resource bundle, we do the following:

try {
     return ResourceBundle.getBundle(resource, locale);
     } catch (MissingResourceException mre) {

         // This covers the case where neither the
         // requested locale or the default locale
         // have a resource.
         return ResourceBundle.getBundle(resource, EN);
     }


Is there a reason why we're not making use of the fallback code that 
ResourceBundle already provides for us, and instead writing our own 
fallback code which depends on an exception?

I recognize that in the engine "messages_en.properties" is split up into 
about 50 files of the format mNN_en.properties, but couldn't we just as 
easily split up messages.properties into mNN.properties?

Thanks,

David

Mime
View raw message