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(...)


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