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, entry)
10 key = :other unless entry.has_key?(key)
11 raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
12 translation entry[key], :plural_key => key
15 def add_pluralizer(locale, pluralizer)
16 pluralizers[locale.to_sym] = pluralizer
19 def pluralizer(locale)
20 pluralizers[locale.to_sym] || default_pluralizer
24 def default_pluralizer
30 :en => lambda { |count, entry|
36 :ru => lambda { |count, entry|
38 when 11,12,13,14 then :many
42 when 5,6,7,8,9,0 then :many
47 :sl => lambda { |count, entry|
58 # Overwrite this method to return something other than a String
59 def translation(string, attributes)