Plural forms and I18NCreator

62 views
Skip to first unread message

Raphael André Bauer

unread,
May 13, 2011, 4:09:06 AM5/13/11
to google-web-toolkit
Hi everybody,


we are trying to generate i18n interfaces from our property files via
the com.google.gwt.i18n.tools.I18NCreator. In principle it works
perfectly fine.

But there is one thing that does not work: Generating the interface
from plural forms [1] using com.google.gwt.i18n.tools.I18NCreator .

Something like:

cartItems=There are {0,number} items in your cart.
cartItems[one]=There is {0,number} item in your cart.

should become:

@DefaultLocale("en") // not required since this is the default
public class MyMessages extends Messages {
@DefaultText("There are {0,number} items in your cart.")
@PluralText({"one", "There is 1 item in your cart.")
String cartItems(@PluralCount int itemCount);
}

...but does not get converted in an interface.

Does anybody know if that’s our fault or just not supported
com.google.gwt.i18n.tools.I18NCreator (GWT 2.3)?


Thanks a lot,

Raphael


[1] http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideI18nPluralForms.html

John A. Tamplin

unread,
Jun 17, 2011, 12:10:33 AM6/17/11
to google-we...@googlegroups.com
This is not supported.  The problem is the information simply isn't there to convert from the properties file to the fully typed Java interface without adding some convention for comments specifying that information -- if you are going to do that, you might as well just write the Java code.

For example:

msg=They gave you a widget.
msg[FEMALE]=She gave you a widget.
msg[MALE]=He gave you a widget.

How are you supposed to get the type of the @Select parameter (assuming you infer it)?  It could be a String or an Enum, and if an Enum which one should you use?

How do you get the argument names or types?  Ie:

msg=Your total is {0}

Is argument 0 an int, double, BigDecimal, or something else?
Reply all
Reply to author
Forward
0 new messages