ruby-i18n / i18n

Internationalization (i18n) library for Ruby
MIT License
977 stars 408 forks source link

[BUG] Following `Symbols` doesn't work with Pluralization lookup #635

Closed movermeyer closed 1 year ago

movermeyer commented 2 years ago

What I tried to do

I'm creating an issue to capture the problem laid out in https://github.com/ruby-i18n/i18n/pull/480 by @Tietew

Using links/Symbols/aliases (whatever you call 'em) and pluralization (i.e., count) doesn't work.

autos: :cars
cars: 
  porsche:
    one: "I have %{count} Porsche πŸš—"
    other: "I have %{count} Porsches πŸš—"
I18n.t(:'autos.porsche', count: 1)

What I expected to happen

"I have 1 Porsche πŸš—"

What actually happened

I18n::InvalidPluralizationData: translation data {:porsche=>{:one=>"I have %{count} Porsche πŸš—", :other=>"I have %{count} Porsches πŸš—"}} can not be used with :count => 1. key 'one' is missing.

What is happening?

The issue is occurring in the lookup of the linked data.

Since all the original parameters are passed into the sublookup, including count, it is attempting to perform the pluralization lookup prior to returning the resolved value and failing.

History of this issue

Q&A

Q: Why wasn't this noticed by the tests when the changes to Backend::Pluralization were reverted?

A: There was no test with both symbol resolution and pluralization in the Backend::Pluralization tests.

The #480 changes were reverted, but not the #503 changes, so the test added in #480 for Backend::Base didn't start failing.

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

i18n 1.12.0 (and many prior versions)