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

Pluralization of negative amounts is always :other #270

Open
kikito opened this issue Oct 27, 2012 · 9 comments
Open

Pluralization of negative amounts is always :other #270

kikito opened this issue Oct 27, 2012 · 9 comments

Comments

@kikito
Copy link

kikito commented Oct 27, 2012

Hello there,

Say I want to translate a pluralizable message such as this one:

en:
  tempetature:
    one: "Temperature: %{count} degree"
    other: "Temperature: %{count} degrees"

This works with positive values and 0:

I18n.t("temperature", :count => 1) # Temperature: 1 degree
I18n.t("temperature", :count => 22) # Temperature: 22 degrees
I18n.t("temperature", :count => 0) # Temperature: 0 degrees

But the way the pluralization rules are written, the :other option is returned for all negative numbers. Notably, -1 is treated as other:

I18n.t("temperature" , :count => 1) # Temperature: -1 degrees (instead of -1 degree)

I know this doesn't look like a bit deal in English, but in other locales such as Russian this might be more complex. Probably they'll want to use :one for -1, :few for -4 and so on. So maybe there is an abs missing there somewhere. Or maybe not - I don't speak Russian.

My point is that negative amounts are always pluralized as :other by the lib, but I doubt all languages in the world agree in something like that (It would be too good to be true).

Unfortunately, the CLDR table ignores negative numbers. I've opened an issue on the CLDR tracker, but it could take these guys a long time to complete that list.

This lib only has 7 pluralizers, so it should take us less time to sort that out. I don't know the due procedures though - do you guys have one language expert per pluralizer, or something similar?

@kuroda
Copy link
Collaborator

kuroda commented Oct 28, 2012

@kikito

This repository is just for the collection and maintenance of I18n data.

Please visit https://github.com/svenfuchs/i18n for the behaviour of I18n library.

@kuroda kuroda closed this as completed Oct 28, 2012
@kikito
Copy link
Author

kikito commented Oct 28, 2012

Hi @kuroda,

Thanks for answering. But I think you might have read my post a bit too quickly.

The problem I'm referring to is not with I18n, but with the data itself.

Concretely, with the files in this location:

https://github.com/svenfuchs/rails-i18n/tree/master/lib/rails_i18n/common_pluralizations

Please consider reopening this issue.

Best regards,

Enrique

@tigrish
Copy link
Contributor

tigrish commented Oct 28, 2012

Hi @kikito you raise a good point, and one that I hadn't even considered before.

Given how complicated some of these pluralization rules can be, I'd feel uncomfortable just adding an abs() call in I18n's pluralization method without having some kind of confirmation that this is applicable to all locales.

Can you post the link to the issue you'e opened?

Until the CLDR addresses this issue the quickest/easiest solution might be to just re-submit amended pluralization rules here.

@kikito
Copy link
Author

kikito commented Oct 28, 2012

Hi @tigrish,

Here's the ticket I opened:

http://unicode.org/cldr/trac/ticket/5415

It doesn't look like it has moved much since I opened it. I assume that the cldr is not able to move very fast.

I'd feel uncomfortable just adding an abs() call in I18n's pluralization method without having some kind of confirmation that this is applicable to all locales.

I'm no linguist, but I can could confirm that Spanish, French, English, Portuguese and Russian do abs() on negative numbers by asking around. It know this is not enough evidence to change all the rules to do abs by default, but it indicates a malfunction on those locales.

Until the CLDR addresses this issue the quickest/easiest solution might be to just re-submit amended pluralization rules here.

I'm pretty confident I can send a pull request wich invokes abs() on the passed param. Is that what you are saying?

@tigrish
Copy link
Contributor

tigrish commented Oct 28, 2012

I was more thinking of resubmitting the rules we know we can fix in rails-i18n/rails/pluralization.

I'll be more than happy to accept a PR that invokes abs() in the I18n repo once we're confident that that's the right thing to do.

@kuroda
Copy link
Collaborator

kuroda commented Oct 28, 2012

@kikito You are right. I'm sorry.

@kuroda kuroda reopened this Oct 28, 2012
@kikito
Copy link
Author

kikito commented Oct 28, 2012

@kuroda No problem, thanks for reopening!

I was more thinking of resubmitting the rules we know we can fix in rails-i18n/rails/pluralization.

@tigrish I'm sorry, I still don't understand what you'd like me to do (or if you want me to do anything).

@mkolodziej
Copy link

This got worse - I'm now getting an error, like this:
translation data {:zero=>"0 odpowiedzi", :one=>"1 odpowiedź", :few=>"%{count} odpowiedzi", :other=>"%{count} odpowiedzi"} can not be used with :count => -4

I had to remove count from the message content and use .abs myself when passing the :count value.

@kikito
Copy link
Author

kikito commented Mar 5, 2013

hi mkolodziej,

You forgot to mention what language is that. Also, please confirm: you also would need i18n to make an 'abs' on the number so it doesn't simply return :other for negative numbers, right?

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

No branches or pull requests

4 participants