commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Meder <>
Subject Re: [resources] 1.0.0 Release Candidate 1
Date Mon, 28 Nov 2005 20:43:09 GMT
On Mon, 2005-11-28 at 03:00 +0000, Niall Pemberton wrote:
> On 11/28/05, Craig McClanahan <> wrote:
> > On 11/27/05, Niall Pemberton <> wrote:
> > >
> > > A couple of questions I had on the resources API:
> > >
> > > 1) I was wondering why TimeZone is include in the Resources's content
> > > read methods? Is there a use case, for example, for giving west coast
> > > Americans a different message to east coast?
> >
> >
> > Some of the format options for displaying times take a time zone parameter
> > (so that it can be included in the emitted string).  Simply pass null if it
> > doesn't matter to you.
> I don't see any valid formats specified in java.text.MessageFormat
> that take a TimeZone. Thats slightly irrelevant though since AFAIK
> Commons Resources doesn't deal anywhere with message formats. My
> understanding that happends after the resource has been retrieved,
> something like....
>     String msgResource = myResources.getString("foo.key", locale, null);
>     MessageFormat msgFormat = new MessageFormat(msgResource);
>     msgFormat.setLocale(locale);
>     String message = msgFormat.format(args);
> Have I got the wrong end of the stick on this? Struts MessageResources
> does do the MessageFormat bit, but Commons Resources doesn't.

Actually I just nuked my reply (still stuck on my laptop) which
reiterated my concern from my mail a couple of days that
MessageResources and the MessageFormat stuff is missing like you did.
But I guess I found it: it's in Messages.

So I guess it should be more along the line:

Messages myMsgResources = new Messages(myResources);
String message = myMsgResources.getMessage(locale, "foo.key", args);

But there are some things which should get improved wrt Messages:

* include all parametric replacement options like in Struts
MessageResources (not only arg0 and [] args)
* the order of locale and key is reversed compared to Resources, it's
(locale, key); Resources is (key, locale)
* MessageFormat isn't cached as it is in Struts MessageResources
* setLocale isn't called on the used MessageFormat instances
* the TimeZone parameter isn't used like in the rest of

If nobody objects I'll whip up patches for the above points.



Christian Meder, email:

The Way-Seeking Mind of a tenzo is actualized 
by rolling up your sleeves.

                (Eihei Dogen Zenji)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message