Wednesday, April 24, 2013

Re: Formatting lists with GWT i18n API

And if anyone else stumbles across this in the future like myself make sire there are no spaces between "0", "list" and "text".

On Thursday, 15 December 2011 13:18:35 UTC, Luiz Mineo wrote:
Thanks! It works now. :)

After reading through the GWT doc [1], I thought the third argument
wasn't necessary. Also, I didn't know that 'text' is a valid value for
the format argument, since I found examples only for number and date.

[1]: http://code.google.com/webtoolkit/doc/latest/DevGuideI18nMessages.html#GwtFormats

On Dec 15, 10:23 am, Adam T <adam.t...@gmail.com> wrote:
> Hi Luiz,
>
> If you've not stumbled across this already, just add the format marker
> "text" in your message definitions and it should work, i.e.
>
> @DefaultLocale("pt_BR")
> public interface AppMessages extends Messages {
>
>         @DefaultMessage("elementos: {0,list,text}")
>         @AlternateMessage({"one", "elemento: {0,list,text}"})
>         String formatElements(@PluralCount List<String> elements);
>
> }
>
> //Adam
>
> On 15 Dec, 00:43, Luiz Mineo <luiz.mi...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm trying to format a list of Strings using a Messages interface:
>
> > @DefaultLocale("pt_BR")
> > public interface AppMessages extends Messages {
>
> >         @DefaultMessage("elementos: {0, list}")
> >         @AlternateMessage({"one", "elemento: {0, list}"})
> >         String formatElements(@PluralCount List<String> elements);
>
> > }
>
> > In my module.gwt.xml, I have:
>
> > <!-- languages supported -->
> > <extend-property name="locale" values="pt_BR" />
> > <set-property-fallback name="locale" value="pt_BR" />
>
> > But when I try to format a list, for example:
>
> > AppMessages appMessages = GWT.create(AppMessages.class);
> > appMessages.formatElements(Arrays.asList({"A"}));
> > appMessages.formatElements(Arrays.asList({"A","B","C"}));
>
> > I get:
>
> > "elemento: 1"
> > "elementos: 3"
>
> > Instead of:
>
> > "elemento: A"
> > "elementos: A, B e C"
>
> > I'm using pt_BR for default locale, since it is the only language my
> > app supports for now. Does it only work for en? I tryied to change the
> > default locale for en, but it didn't work either :(
>
> > So, what I'm doing wrong?

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

No comments:

Post a Comment