Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipse-dev] NLS.bind(...) vs MessageFormat.format(...)

The idea of the whole NLS infrastructure is to be fast and small.  If I recall the number correctly it is something like half the size as using resource bundles and twice as fast.  That is for the message management.  Similarly, the bind() infrastructure was a recognition that most cases are very simple and so need only very simple support (read small and fast).  So the guideline would be: use NLS unless you need to do something harder.  And AFAIK you should always use the NLS style message catalog classes.

 

I’d be interested to know if the JFace use of MessageFormat was required or just crept in.

 

Jeff

 

From: eclipse-dev-bounces@xxxxxxxxxxx [mailto:eclipse-dev-bounces@xxxxxxxxxxx] On Behalf Of John Arthorne
Sent: Monday, April 07, 2008 3:53 PM
To: General development mailing list of the Eclipse project.
Subject: Re: [eclipse-dev] NLS.bind(...) vs MessageFormat.format(...)

 


NLS#bind just substitutes values for {0}, {1}, etc, in a message string. That's all it does. If you read the class comment for MessageFormat, you will see the "pattern" argument can actually specify a number of things, such as locale-specific representation of currencies, dates, etc.  If you just want to substitute values into a string, I suggest using NLS (simpler, faster). If you want to do anything else such as locale-specific representation of numbers, use MessageFormat. I've never come across a need for MessageFormat myself, but I believe there is some usage in JFace that you could look at.

John



Olivier Thomann/Ottawa/IBM@IBMCA
Sent by: eclipse-dev-bounces@xxxxxxxxxxx

04/07/2008 01:56 PM

Please respond to
"General development mailing list of the Eclipse project."        <eclipse-dev@xxxxxxxxxxx>

To

eclipse-dev@xxxxxxxxxxx

cc

Subject

[eclipse-dev] NLS.bind(...) vs MessageFormat.format(...)

 




Hi,

I'd like to get some clarification when one method should be used instead
of the other one.
In API Tools, we are trying to use MessageFormat.format(...), but I didn't
know and I ended up using NLS.bind(...).

When I was about to "fix" and go with MessageFormat.format from the ICU
bundle, I made a search for NLS.bind(...) usage and I found many hits. So
I'd like to know when each method should be used.The documentation inside
the NLS class mentioned that this is not a replacement for the
MessageFormat method, but it doesn't really say what kind of limitations
the NLS method has.

Can someone put some light on this, please?

Thanks,

Olivier
_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipse-dev


Back to the top