diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index 672c993c..b04a259e 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -163,6 +163,7 @@ def resolve(locale, object, subject, options = EMPTY_HASH) # not standard with regards to the CLDR pluralization rules. # Other backends can implement more flexible or complex pluralization rules. def pluralize(locale, entry, count) + entry = entry.reject { |k, _v| k == :attributes } if entry.is_a?(Hash) return entry unless entry.is_a?(Hash) && count && entry.values.none? { |v| v.is_a?(Hash) } key = pluralization_key(entry, count) diff --git a/test/backend/pluralization_test.rb b/test/backend/pluralization_test.rb index 1518efdb..d955818e 100644 --- a/test/backend/pluralization_test.rb +++ b/test/backend/pluralization_test.rb @@ -39,6 +39,11 @@ def setup assert_equal 'few', I18n.t(:count => 0, :default => @entry, :locale => :xx) end + test "pluralization picks one for 1 if the entry has attributes hash on unknown locale" do + @entry[:attributes] = { :field => 'field', :second => 'second' } + assert_equal 'one', I18n.t(:count => 1, :default => @entry, :locale => :pirate) + end + test "Fallbacks can pick up rules from fallback locales, too" do assert_equal @rule, I18n.backend.send(:pluralizer, :'xx-XX') end