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

Fix symbol resolving with pluralization #636

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/i18n/backend/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def lookup(locale, key, scope = [], options = EMPTY_HASH)
return nil unless result.has_key?(_key)
end
result = result[_key]
result = resolve_entry(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)
result = resolve_entry(locale, _key, result, Utils.except(options.merge(:scope => nil), :count)) if result.is_a?(Symbol)
result
end
end
Expand Down
10 changes: 10 additions & 0 deletions test/backend/pluralization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ def setup
test "Fallbacks can pick up rules from fallback locales, too" do
assert_equal @rule, I18n.backend.send(:pluralizer, :'xx-XX')
end

test "linked lookup works with pluralization backend" do
I18n.backend.store_translations(:xx, {
:automobiles => :autos,
:autos => :cars,
:cars => { :porsche => { :one => "I have %{count} Porsche 🚗", :other => "I have %{count} Porsches 🚗" } }
})
assert_equal "I have 1 Porsche 🚗", I18n.t(:'automobiles.porsche', count: 1, :locale => :xx)
assert_equal "I have 20 Porsches 🚗", I18n.t(:'automobiles.porsche', count: 20, :locale => :xx)
end
end