I18nCreator creates a message interface with an argument type other than a string

I tried to learn GWT. I completed the StockWatcher example application in the tutorial .

Then I went on to the next step: Internationalization (I18N).

In the I18N tutorial, you create the Message and Constant interfaces manually. One of the message files is as follows:

public interface StockWatcherMessages extends Messages { @DefaultMessage("''{0}'' is not a valid symbol.") String invalidSymbol(String symbol); @DefaultMessage("Last update: {0,date,medium} {0,time,medium}") String lastUpdate(Date timestamp); } 

Pay attention to the parameter of type Date in one of the methods. This allows me to pass a Date instance when I call this method and it displays locally. This worked perfectly.

GWT also has a tool called i18nCreator that you can use to create these interfaces for you based on the corresponding .properties .

I use gwt-maven-plugin to build my application and it also supports using i18nCreator as an automatic part of your build .

So my problem is that when I use i18nCreator, either explicitly or through the maven plugin, I get a message interface like this:

 public interface StockWatcherMessages extends com.google.gwt.i18n.client.Messages { @DefaultMessage("''{0}'' is not a valid symbol.") @Key("invalidSymbol") String invalidSymbol(String arg0); @DefaultMessage("Last update: {0,date,medium} {0,time,medium}") @Key("lastUpdate") String lastUpdate(String arg0); } 

lastUpdate now a string. This calls the rest of my code, which calls this method with a Date instance to compile the compilation.

How can I get i18nCreator to create interfaces using Java types other than strings when necessary? I am having a problem with Date , but I assume that it may occur with other types such as Money or Double or something else.

+4
source share

All Articles