You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Timm, Sean" <ST...@mailgo.com> on 2000/02/04 20:29:25 UTC
XML Resource File?
I'm developing an XML-based resource class for various processors to load up
resource strings from an XML resource file. It got me thinking that it
seems like it would be nice to have this generally available in Cocoon such
that you could call getResourceString at any time, and it would pull the
appropriate string based on what producer/processor you were currently in
for the language you specified.
Unfortunately, I'm probably the wrong guy to throw this into Cocoon since I
know next to nothing about localization (in other words, I've always written
English-only apps).
Maybe something like the following:
-----------------------------------------
<?xml version="1.0"?>
<Resources>
<Strings source="my_processor">
<String name="PASSWORD_REQUIRED">
<Message id="1033">You must enter a password.</Message>
<Message id="1065">wieuyr weurfhisud siufsd (some other
language)</Message>
</String>
</Strings>
</Resources>
-----------------------------------------
Then within my processor, I could do something like the following:
String message = SomeCocoonClass.getResourceString("PASSWORD_REQUIRED",
"1033");
Does anyone else see this as useful, or is this ability already there, and
I'm completely wasting my time? :)
- Sean T.
Re: XML Resource File?
Posted by Mike Engelhart <me...@earthtrip.com>.
Timm, Sean wrote:
> Does anyone else see this as useful, or is this ability already there, and
> I'm completely wasting my time? :)
>
> - Sean T.
java.util.ResourceBundle does this except it doesn't use XML but either
class files or properties files. The implementation is up to the user if
they choose to implement their own classes but most people would use a Map
or Hashtable. Anyway, it seems that since there are a lot of other issues
that ResourceBundle's handle transparently like class naming conventions
that allow the correct bundle to accessed based on the locale, reading files
from Properties files if the correct class isn't found, caching of the
object so it's available without having to reload it and other things, it
seems like you're up a against a pretty good existing model. I'm not sure
what the advantage would be to have the resources stored as XML though?
Isn't it just a key/value pair when it comes down to it?
Mike