1 require 'i18n/backend/simple'
5 class Pluralizing < I18n::Backend::Simple
6 def pluralize(locale, entry, count)
7 return entry unless entry.is_a?(Hash) and count
8 key = :zero if count == 0 && entry.has_key?(:zero)
9 key ||= pluralizer(locale).call(count)
10 raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
11 translation entry[key], :plural_key => key
14 def add_pluralizer(locale, pluralizer)
15 pluralizers[locale.to_sym] = pluralizer
18 def pluralizer(locale)
19 pluralizers[locale.to_sym] || default_pluralizer
23 def default_pluralizer
28 @pluralizers ||= { :en => lambda{|n| n == 1 ? :one : :other } }
31 # Overwrite this method to return something other than a String
32 def translation(string, attributes)