-
Notifications
You must be signed in to change notification settings - Fork 18k
x/text: plural.Zero doesn't work as expected #27724
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
Comments
@odeke-em Can I work on this issue? |
@vikramcse, all yours and thank you! |
@bcmills @odeke-em Hello there
const (
Zero Form = iota
One
Two
Few
Many
Other
) I did try changing above constants structure and run
message.Set(language.English, "%d files remaining",
plural.Selectf(1, "%d",
plural.Two, "2 files remaining",
))
p := message.NewPrinter(language.English)
p.Printf("%d files remaining", 2) In above case we are passing I am not sure how to take this further. EDIT: Thanks |
@mpvl is the right person to help. (He's the primary owner of |
Other has special meaning in CLDR and really should be 0. But I will look in to this. |
This issue is the following: linguistically, English doesn't have a "Zero" plural form, only "One" and "Other" (singular and anything else). Like with ICU, the Go implementation of plurals allows matching to specific numeric values, like =0, but this is not the same as plural.Zero, which will never match in English or, in the example, Dutch. In general, the linguistic plural categories are just names and may often not correspond one-to-one to a particular number. For instance, in Croatian the numbers 1, 21, and 101 are all considered to be plural.One. So "one" and plural.One are equivalent, but "=1" and plural.One, in general, are not. So this is partly a documentation and naming issue. Using plural.Singular instead of plural.One, for instance, would have been clearer, in English. However, that approach wouldn't scale. The numeric names only loosely match a myriad of plural categories in different languages. The documentation states that the plural categories do not correspond one-to-one with numbers. The naming is also the standard naming from ICU/CLDR. But I'm open to suggestions as to how to make this clearer. |
working as intended. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
I expect to see the same results regardless if using
"=0"
orplural.Zero
.What did you see instead?
I see the example code silently ignoring pluralization cases.
The text was updated successfully, but these errors were encountered: