Skip to content

Commit

Permalink
Merge pull request #636 from movermeyer/movermeyer/pluralization_and_…
Browse files Browse the repository at this point in the history
…symbol_resolution

Fix symbol resolving with pluralization
  • Loading branch information
radar authored Oct 6, 2022
2 parents 32c957e + 88c31c7 commit c5ccd28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit c5ccd28

Please sign in to comment.