tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keyur Shah <ks...@esri.com>
Subject XML ResourceBundles
Date Mon, 29 Sep 2003 23:35:03 GMT
I want to localize my messages using XML files. Now, I want to have only one
MyXMLResourceBundle (which extends ResourceBundle) as such:




public class MyXMLResourceBundle extends ResourceBundle {


   private Locale locale;


   public MyXMLResourceBundle(Locale locale) {


      this.locale = locale;


      //load resources from an XML file based on the locale


   }


   //override ResourceBundle.getLocale()


   public Locale getLocale() { return this.locale; }


   //other methods


}


I will be using a combo of JSTL and JSF tags in my application to output
texts. As per my understanding, both of these taglibs call
ResourceBundle.getBundle(baseName, locale) to get the appropriate bundle.
Now, the problem is this:

Say, the locale is french - "fr". The getBundle() method tries to find
MyXMLResourceBundle_fr.class first and then it attempts to find
MyXMLResourceBundle.properties. Now, I have none of these files in my app.
(What I have are MyXMLResourceBundle.class and MyXMLResourceBundle_fr.xml
files.) Since it cannot find the mentioned files; what ends up happening is
that the getBundle() method always ends up using the same
MyXMLResourceBundle instance with the default locale.

What I want to see happen is this: for every different locale it should
create a new instance of MyXMLResourceBundle and use the appropriate
localized XML file i.e. the ResourceBundle.getBundle() method should call
the MyXMLResourceBundle(locale) constructor with the appropriate locale.

Now, since I don't have any control over the ResourceBundle methods(!), I'd
like to know if there is any other way for me to use XML resource bundles
and make them work with the existing JSTL / JSF tags all the same.

Thanks.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message