ResourceBundle with Database backend
Hi all,
We're busy creating a web application that needs different localization.
ResourceBundles would probably be the best thing to use for this. However,
we would like to use a database as the backend for the ResourceBundle.
This would make changing and adding translated strings much easier. We
would like our client to be able to do this himself, using a front end we
will write.
From what I understand of ResourceBundles, we would have to create a
ResourceBundle class for each translation. We'd like to create just one
subclass of ResourceBundle however, which handles all translations. Is
this possible? I can't find any examples of how this should work..
thanks for thinking along, please tell me if my question isn't completely
clear or something like that,
Ilja Booij
MMS2P B.V.
[884 byte] By [
i.booija] at [2007-10-2 0:26:53]

Hi Ilja,
I don't know if I understand your problem correctly.
I did a resource bundle based on DB. I did one class that extended ResourceBundle and this one implements all the read and write to the DB.
But in order to use on my web applications I have to extend my DatabaseResourceBundle class and just implement one simple method that is the name of the resource that I wanna store on the DB.
I still have to create the classes for each language I want, but there is not code on those classes. The resources are required in order of the resource bundle know which language should read or write on the db.
I am using Struts on my web applicataions, so I also extended the MessageResourcesFactory to use my DatabaseResourceBundle implementation. It's now using all the bundles from the DB and we can change the messages on the db through a web tools to edit bundles. The messages are cached for N minutes specified by a JMX constant that can be changed at any time. or you can call a reload method to force to expire the bundle cache.
Hope I helped and gave you some ideas for implementation.
Regards,
Bruno
Hi,
I am trying to do the same thing. I extended the Resourcebundle and created one class.
In that class I have a method which will return the text stored in the DB for a particular country & language or if it is not provided will use default locale.
I dont understand why you have to create classes for each language..?
Can you explain it?
Thanks