gwtproject / gwt

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

i18nCreator does not recognize MessageFormat/GWT format types #6923

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 6924

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

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):
N/A

Detailed description (please be as specific as possible):
The i18nCreator tool does not take into account the different MessageFormat/GWT formatting
types when generating the source code for a Messages interface.  The parameters of
the generated methods are always Strings, which generates an error on application startup
if any of the message arguments use a formatter.  The parameters should be different
types, depending on the formatting type.  For example:

number: java.lang.Number
date: java.util.Date
list: java.util.List
localdatetime: java.util.Date

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):

.properties file:

    my.message=File is {0,number,0.0}MB in size.
    my.list=A list of numbers: {0,list,number,0.0}

Expected result:

    public interface Messages extends com.google.gwt.i18n.client.Messages {
      @DefaultMessage("File is {0,number,0.0}MB in size.")
      @Key("my.message")
      String my_message(Number arg0);

      @DefaultMessage("A list of numbers: {0,list,number,0.0}")
      @Key("my.list")
      String my_list(List<Number> arg0);
    }

Actual result:

    public interface Messages extends com.google.gwt.i18n.client.Messages {
      @DefaultMessage("File is {0,number,0.0}MB in size.")
      @Key("my.message")
      String my_message(String arg0);

      @DefaultMessage("A list of numbers: {0,list,number,0.0}")
      @Key("my.list")
      String my_list(String arg0);
    }

Workaround if you have one:
Edit the generated source code by hand after running the i18nCreator script.

Links to relevant GWT Developer Forum posts:
None

Reported by mike.angstadt on 2011-10-25 17:06:34

dankurka commented 9 years ago

Reported by rdayal@google.com on 2011-11-04 19:56:54

dankurka commented 9 years ago

Reported by unnurg@google.com on 2011-11-04 20:10:02

dankurka commented 9 years ago

Reported by rdayal@google.com on 2011-11-11 21:45:45

dankurka commented 9 years ago

Reported by dankurka@google.com on 2013-06-02 20:47:05