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

Hi,

An interesting thing with MessageFormat from JDK is that it's not part of "CDC Foundation 1.0" so e.g. JFace should not use it although it does (See https://bugs.eclipse.org/bugs/show_bug.cgi?id=209108)

Tom

Markus Keller schrieb:
Note that even if the values are plain numbers (int, double, ...), you should use MessageFormat. The difference is that NLS#bind(..) does not support e.g. locale-specific thousands separators.

=> Just assume that the 'binding' parameters of the NLS#bind(..) methods are of type 'String', not 'Object', and then ask yourself whether String#valueOf(..) on the concrete arguments would be correct.

Markus





John Arthorne <John_Arthorne@xxxxxxxxxx> Sent by: eclipse-dev-bounces@xxxxxxxxxxx
2008-04-07 21:53
Please respond to
"General development mailing list of the Eclipse project." <eclipse-dev@xxxxxxxxxxx>


To
"General development mailing list of the Eclipse project." <eclipse-dev@xxxxxxxxxxx>
cc

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
_______________________________________________
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


_______________________________________________
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


--
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                               leiter softwareentwicklung/CSO
------------------------------------------------------------------------
eduard-bodem-gasse 8/3    A-6020 innsbruck      phone    ++43 512 935834


Back to the top