Wednesday, September 1, 2010

Messages with plural text in a property file

Hi,

I have written a GWT application which uses the Messages interface to
render all the strings across the app. I would have liked to use the
Plural text feature to render the string differently according to a
"count" parameter. Unfortunately, I can't get this to work, I
constantly get the default value

This is how I have done this so far:
In my interface extending Messages:

public interface PBVMessageConstants extends Messages {
public static final PBVMessageConstants instance =
GWT.create(PBVMessageConstants.class);

public String addOrderItemTooltip(@PluralCount @Optional int
itemCount);

// ... and many more methods
}

and in the PBVMessageConstants.properties file I have:

addOrderItemTooltip=Add these items to your selection
addOrderItemTooltip[one]=Add this item to your selection

I then invoke the interface like this:
PBVMessageConstants.instance.addOrderItemTooltip(products.size())
but even when the products List has only one item, I still have the
plural message

Am I missing something obvious? Thanks in advance to anyone who can
help me.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment