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

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

Open
JasonBarnabe opened this issue Oct 25, 2024 · 0 comments · May be fixed by #707
Open

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

JasonBarnabe opened this issue Oct 25, 2024 · 0 comments · May be fixed by #707

Comments

@JasonBarnabe
Copy link

What I tried to do

I am using Transifex on devise-i18n for localization. This lets translators do their work with a web UI and I (the dev) can pull from Transifex.

In this project, I include translations for some locales where pluralization rules are not specified by svenfuchs/rails-i18n: Igbo (ig) and Yoruba (yo). For these languages, Transifex uses the other-only plural form, which is correct according the Plural Language Rules.

What I expected to happen

I expected to be able to use these translations with the correct plural forms as provided by Transifex.

What actually happened

I18n::InvalidPluralizationData: translation data {:other=>"%{count}àsìse sèdíwọ elè yìí %{resource} láti lè fi pamọ́"} can not be used with :count => 1. key 'one' is missing.

Digging through the code, I found the logic here:

def pluralization_key(entry, count)
key = :zero if count == 0 && entry.has_key?(:zero)
key ||= count == 1 ? :one : :other
end

Considering it's smart enough to check for the presence of a zero key before using it, why not do the same for one? That way, for locales without pluralization data, having other is sufficient to avoid an error.

As a workaround, I can manually duplicate the others into ones for both of these locales, but that's a hassle.

Versions of i18n, rails, and anything else you think is necessary

  • i18n 1.14.6
  • rails-i18n 7.0.8
JasonBarnabe added a commit to devise-i18n/i18n that referenced this issue Oct 26, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant