module I18n::Backend::Pluralization

def pluralize(locale, entry, count)

pluralizer does not return a :zero key.
either pick a special :zero translation even for languages where the
translation data has the key :zero. This way translators are free to
The :zero key is always picked directly when count equals 0 AND the

i.e., return one of the keys :zero, :one, :few, :many, :other.
hash (entry) but it is generally recommended to follow CLDR's style,
return a pluralization key. Valid keys depend on the translation data
Pluralization rules are expected to respond to #call(count) and

pluralization rules to be stored at I18n.t(:'i18n.plural.rule')
rule and use it to pluralize the given entry. I.e. the library expects
translation meta data space (:i18n) for a locale specific pluralization
Overwrites the Base backend translate method so that it will check the
def pluralize(locale, entry, count)
  return entry unless entry.is_a?(Hash) && count
  pluralizer = pluralizer(locale)
  if pluralizer.respond_to?(:call)
    key = count == 0 && entry.has_key?(:zero) ? :zero : pluralizer.call(count)
    raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
    entry[key]
  else
    super
  end
end

def pluralizer(locale)

def pluralizer(locale)
  pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false)
end

def pluralizers

def pluralizers
  @pluralizers ||= {}
end