Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties generated from plural form of messages does not have the exact values #7032

Closed
dankurka opened this issue Jun 10, 2015 · 7 comments

Comments

@dankurka
Copy link
Member

Originally reported on Google Code with ID 7033

Found in GWT Release (e.g. 2.4.0, 2.5.0 RC):
2.4.0


Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):
Linux/Mac


Detailed description (please be as specific as possible):
Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):

Followed the example on http://code.google.com/webtoolkit/doc/latest/DevGuideI18nPluralForms.html#ExactValues
 - change class to interface
 - add a '}', and removed the ','
 - add Generate annotations
The finale file looks like this:

import com.google.gwt.i18n.client.Messages;
import com.google.gwt.i18n.client.LocalizableResource.Generate;
import com.google.gwt.i18n.client.LocalizableResource.GenerateKeys;

@GenerateKeys("com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator")
@Generate(format = "com.google.gwt.i18n.rebind.format.PropertiesFormat")
public interface MyMessages extends Messages {
  @DefaultMessage("There are {0,number} items in your cart.")
  @AlternateMessage({
      "one", "There is 1 item in your cart.",
      "=0", "Your cart is empty."}
  )
  String cartItems(@PluralCount int itemCount);
}

Build the project, and we get the generated properties.

# Generated from package.MyMessages
# for locale en

#0=itemCount (Plural Count)
27565F45701C96702BC47C35BE474252=There are {0,number} items in your cart.

I am expecting to have this line as well:
cartItems[\=0]=Your cart is empty.





Links to relevant GWT Developer Forum posts:
There is also one post about the issue in the forum.
https://groups.google.com/group/google-web-toolkit/browse_thread/thread/f9ba73449ce60c70/9160c4546547533e?lnk=gst&q=plural#9160c4546547533e



Reported by lsong@google.com on 2011-11-29 23:07:54

@dankurka dankurka self-assigned this Jun 10, 2015
@dankurka
Copy link
Member Author

Reported by jat@google.com on 2011-11-30 21:13:44

  • Status changed: Accepted
  • Labels added: Category-I18N, Type-Defect

@dankurka
Copy link
Member Author

This is a general problem with @AlternateMessage.
Selectors are also not exported.

Reported by tomer.barkai@takadu.com on 2012-04-15 12:18:13

@dankurka
Copy link
Member Author

You are probably generating only the "default" locale, which doesn't have plural forms.
 Try using a real locale, such as:

@Generate(format = "com.google.gwt.i18n.rebind.format.PropertiesFormat",
    locales = ["en_US"])
@DefaultLocale("en_US")
public interface MyMessages extends Messages {
...

and then of course you have to build including the en_US locale (substitute whatever
locale your messages are written in).  For development, you can include
  <extend-property name="locale" values="en_US"/>
  <set-property name="locale" value="en_US"/>
  <set-property-fallback name="locale" value="en_US"/>
in the module you use for development.

Reported by jat@google.com on 2012-04-15 12:39:27

@dankurka
Copy link
Member Author

Thanks for the answer - it works for plural forms! (but isn't =\d the way plural forms
are supported in the default locale? Shouldn't properties named cartItems[\=0] and
cartItems be created?)

The selectors are still not exported. For example:

@DefaultMessage("None")
@AlternateMessage({
  "ANY", "All events",
  "AGGREGATED", "Groups only",
  "UNAGGREGATED", "Singles only"})
String aggregateStateDisplayName(@Select AggregateState state);

Yields:

# 0=state (Selector)
aggregateStateDisplayName=None

Reported by tomer.barkai@takadu.com on 2012-04-16 04:41:05

@dankurka
Copy link
Member Author

I haven't had time to setup a repro case, but just looking at it I think the issue is
using the old PropertiesFormat rather than PropertyCatalogFactory (docs probably need
to be updated).

Perhaps there should be a warning when generating an output file using an old-style
MessageCatalogFormat if anything is present in any of the messages which can't be represented
in that API.

Reported by jat@google.com on 2012-04-16 13:55:39

@dankurka
Copy link
Member Author

Thank you!!

@Generate(format = "com.google.gwt.i18n.server.PropertyCatalogFactory")
solved it.
And plural forms now work for the default locale as well!

Reported by tomer.barkai@takadu.com on 2012-04-17 05:02:12

@dankurka
Copy link
Member Author

Reported by dankurka@google.com on 2013-05-28 07:00:58

  • Status changed: AssumedStale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant