[BUG] Following `Symbols` doesn't work with Pluralization lookup
movermeyer opened this issue ยท 0 comments
What I tried to do
I'm creating an issue to capture the problem laid out in #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
- This was noticed by #480 and the fix was to exclude the
count
parameter within the Symbol resolving code. - This broke Symbol resolving within
default
and an attempt was made to fix it in a different way (#503) - #503 implicitly changed the definition of what was permitted in a translation file (namely, it broke nested keys within pluralization contexts), causing and #510 and #514.
- #503 was partially reverted in 1b5e345, leaving us in the state we have today:
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)