Skip to content

Conversation

JasonBarnabe
Copy link

Previously, the 'one' and 'other' subkeys were both required, with the 'zero' subkey being optionally used. This failed for some languages that do not have a 'one' form. All languages have an 'other' form, so make that the only subkey that's required, and turn 'one' into an optional subkey just like 'zero'.

Fixes #706

…les are undefined

Previously, the 'one' and 'other' subkeys were both required, with the 'zero' subkey being optionally used. This failed for some languages that do not have a 'one' form. All languages have an 'other' form, so make that the only subkey that's required, and turn 'one' into an optional subkey just like 'zero'.

Fixes ruby-i18n#706
# :one subkey present.
# - It will pick the :other subkey otherwise.
# - It will pick the :zero subkey in the special case where count is
# equal to 0 and there is a :zero subkey present. This behaviour is
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether this "not standard" comment means the behaviour is not standard in relation to the CLDR English pluralization rules (because there is a zero subkey) or if there is some sort "generic/unknown locale" rule in CLDR that it's deviating from in some way. If I could get an answer on that I could update the comment to be clearer.

@JasonBarnabe
Copy link
Author

Can someone take a look at this? I'm waiting on a decision here to do a release of https://github.com/devise-i18n/devise-i18n.

@hatajoe
Copy link

hatajoe commented Jul 22, 2025

I'm facing following error on my app with devise-i18n v1.13.0.

****(dev)> I18n.t('activerecord.models.user', locale: :ja, count: 0)
=> "ユーザー"
****(dev)> I18n.t('activerecord.models.user', locale: :ja, count: 1)
(****):2:in `<main>': translation data {:other=>"ユーザー"} can not be used with :count => 1. key 'one' is missing. (I18n::InvalidPluralizationData)

              old_raise.call(*args, **kwargs)
                             ^^^^^^^^^^^^^^^
****(dev)> I18n.t('activerecord.models.user', locale: :ja, count: 2)
=> "ユーザー"

I believe the error will be occurred in languages that doesn't have singular form like Japanese, Korean and etc.
ref: https://www.unicode.org/cldr/charts/47/supplemental/language_plural_rules.html

The above error could be solved to pull this pull-request changes, and this changes look makes sense to me.
Can someone take a look at this?

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

Successfully merging this pull request may close these issues.

[BUG] Pluralization rules for unknown locales require 'one' and 'other' keys

2 participants