I'm back with more clues. =)
I wanted to add some locales to my module. Figured I could get a
boiler plate for the properties file if I used the @Generate
annotation. I noticed that it created both an "_en.properties" file
and a "_default.properties". What's more; the "_en" file completely
lacked the plural form info! The "_default" file had them though.
I then moved the "_defaults" file to the same directory as my
TimeMessages.java file and renamed it
"TimeMessages_default.properties".
With this in place I can remove <extend-property name="locale"
values="en"/> from my module's .gwt.xml file and, more important, the
"&locale=en" from the URL when running my app. I still need the
@DefaultLocale("en") annotation though, even though the documentation
clearly states that this is not necessary.
In conclusion, if you run in to this problem, try
- generating properties files using @Generate
- place YourMessages_default.properties side by side with
YourMessages.java
- prepend the YourMessages interface with a @DefaultLocale("en")
annotation.
About that @Generate. This is what worked for me. Just before my
extension of the Message interface:
@Generate(format =
{"com.google.gwt.i18n.rebind.format.PropertiesFormat"})
The GWT log said it created my properties file, but I couldn't find
it. I fixed that by adding the compiler flag "-extra extras" and then
found the properties files generated in the "extras" directory.
Including this info here since I spent more than an hour figuring it
out.
Seriously, this part of the GWT docs is not up to the standards of
what's common with GWT. Is there anyway I can help with fixing that?
Regards,
/PEZ
On Jun 11, 11:05 am, PEZ <[email protected]> wrote:
> Finally got some traction thanks to the clues I got from Federico
> Kerek, author of Essential GWT -http://my.safaribooksonline.com/9780321705631
>
> It seems like it is something I don't understand with the default
> locale mechanism. I haven't figured it out, but it seems that to get
> plural handling to work I need:
>
> - In my module's gwt.xml file:
> <extend-property name="locale" values="en"/>
> - In my Messages extentsion:
> @DefaultLocale("en")
> public interface MyMessages extends Messages ...
> - Explicitly load the "en" locale by appending to the URL
> &locale=en
>
> Does this provide enough clues for anyone to see where I might be
> doing this wrong?
>
> Regards,
> /PEZ
>
> On Jun 10, 2:54 pm, PEZ <[email protected]> wrote:
>
>
>
> > I'm using GWT 2.0.3. I have now also tried using a .properties file
> > instead. Like so:
>
> > hours[one]=an hour
> > hours={0} {1,number} hours {2}
>
> > With the same, boring, results.
>
> > /PEZ
>
> > On Jun 9, 10:38 pm, PEZ <[email protected]> wrote:
>
> > > I'm making (porting really) a "relative time" module for human
> > > readable date-and-time messages to GWT. The first (alpha-ish) version
> > > is up on Github:http://github.com/PEZ/GWT-Relative-Time
>
> > > Anyone who tries it will notice that it reports all times as plurals.
> > > When it should say "an hour ago", it says "1 hours ago". My messages
> > > interface looks like so:
>
> > > public interface TimeMessages extends Messages {
> > > ...
> > > @DefaultMessage("{0} {1,number} hours {2}")
> > > @PluralText({"one", "an hour"})
> > > String hours(String prefix, @PluralCount int count, String
> > > suffix);
> > > ...
>
> > > }
>
> > > From what I can understand of the documentation, that is how you
> > > should be able to deal with singular and plural forms, right? Well, it
> > > doesn't work. Anyone who knows how this works? Or, if it's a bug in
> > > GWT, can I work myself around it?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.