gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.53k stars 377 forks source link

GWT compiler error when using localization messages with "number,integer" format #7049

Open dankurka opened 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7051

Found in GWT Release (e.g. 2.4.0, 2.5.0 RC):
2.4.0

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):
Windows 7, 64-bit
IE9

Detailed description (please be as specific as possible):
When you have an implementation of com.google.gwt.i18n.client.Messages and a corresponding
property file with something like:
There are {0,number,integer} dogs
the GWT compiler gives a compilation error:

Scanning for additional dependencies: file:/MyMessages.java
     [java]       Adding '1' new generated units
     [java]          Validating newly compiled units
[...]
     [java]             Ignored 1 unit with compilation errors in first pass.
     [java] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all
errors.
     [java]    [ERROR] Errors in 'generated://EF3CE6BF7B0DA7E03615146415064F3D/path/to/MyMessages_.java'
     [java]       [ERROR] Line 6:  The method getIntegerFormat() is undefined for the
type NumberFormat
     [java]       [ERROR] Line 14:  The method getIntegerFormat() is undefined for
the type NumberFormat
     [java]    [ERROR] Cannot proceed due to previous errors

I think the GWT compiler is doing a wrong method search for NumberFormat.getIntegerFormat(),
while the correct one is NumberFormat.getIntegerInstance().

Workaround if you have one:
None.

Reported by mauromol@tiscali.it on 2011-12-04 18:54:02

dankurka commented 9 years ago

Reported by rdayal@google.com on 2011-12-07 16:29:01

dankurka commented 9 years ago
John - does this sound right to you?

Reported by unnurg@google.com on 2011-12-14 22:00:11

dankurka commented 9 years ago
Yes -- amazing that this has never worked and was not noticed before now.  Basically,
this came from ICU's MessageFormat, yet GWT's NumberFormat doesn't actually have getIntegerInstance().

I think the most straightforward fix is to replace ".getIntegerFormat()" in MessagesMethodCreator.NumberFormatter.format
with ".getDecimalFormat().overrideFractionDigits(0)" -- and of course adding some tests.

Reported by jat@google.com on 2011-12-14 22:28:05

dankurka commented 9 years ago
Is there any chance, that this will be fixed soon? I came up to this right now. It is
really bad. Or is there any workaround available now? (two years later)

Is there another way to pass in an integer or long parameter value with the locale
specific messages interface?

Reported by benjamin.gruenebast on 2013-04-22 13:12:47

dankurka commented 9 years ago
John might fix it as he's working on his big I18N patch, but otherwise patches are welcome
(it's a simple fix, ideal for a first contribution; the hardest part would be writing
tests).

Reported by t.broyer on 2013-04-22 13:50:22

dankurka commented 9 years ago
Hello,

I have just submitted a patch for this issue. Here is the link: https://gwt-review.googlesource.com/#/c/12430/

This is my first contribution to gwt so please let me know if I need to do anything
else to get it accepted.

Thanks

Reported by josephadams9 on 2015-04-09 18:15:21