Skip to content

Commit

Permalink
Preserve count option
Browse files Browse the repository at this point in the history
  • Loading branch information
CrAsH1101 committed Dec 17, 2019
1 parent 06aa9ac commit 9a5ae3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/i18n/backend/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def resolve(locale, object, subject, options = EMPTY_HASH)
result = catch(:exception) do
case subject
when Symbol
I18n.translate(subject, **options.merge(:locale => locale, :throw => true).except(:count))
I18n.translate(subject, **options.merge(:locale => locale, :throw => true))
when Proc
date_or_time = options.delete(:object) || object
resolve(locale, object, subject.call(date_or_time, options))
Expand All @@ -163,7 +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)
return entry unless entry.is_a?(Hash) && count
return entry unless entry.is_a?(Hash) && count && entry.values.select{|v| v.is_a?(Hash)}.size == 0

key = pluralization_key(entry, count)
raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/backend/pluralization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Pluralization
# either pick a special :zero translation even for languages where the
# pluralizer does not return a :zero key.
def pluralize(locale, entry, count)
return entry unless entry.is_a?(Hash) and count
return entry unless entry.is_a?(Hash) && count && entry.values.select{|v| v.is_a?(Hash)}.size == 0

pluralizer = pluralizer(locale)
if pluralizer.respond_to?(:call)
Expand Down

0 comments on commit 9a5ae3e

Please sign in to comment.