X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/d0b845fc6025f2fb84a4cf4fa10cbb71084843a7..3e8b62dbfe5a34c87936b044869af4968f836c6f:/vendor/plugins/globalize2/lib/globalize/backend/pluralizing.rb diff --git a/vendor/plugins/globalize2/lib/globalize/backend/pluralizing.rb b/vendor/plugins/globalize2/lib/globalize/backend/pluralizing.rb index 80016f208..9dd9bb667 100644 --- a/vendor/plugins/globalize2/lib/globalize/backend/pluralizing.rb +++ b/vendor/plugins/globalize2/lib/globalize/backend/pluralizing.rb @@ -6,7 +6,8 @@ module Globalize def pluralize(locale, entry, count) return entry unless entry.is_a?(Hash) and count key = :zero if count == 0 && entry.has_key?(:zero) - key ||= pluralizer(locale).call(count) + key ||= pluralizer(locale).call(count, entry) + key = :other unless entry.has_key?(key) raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) translation entry[key], :plural_key => key end @@ -25,7 +26,33 @@ module Globalize end def pluralizers - @pluralizers ||= { :en => lambda{|n| n == 1 ? :one : :other } } + @pluralizers ||= { + :en => lambda { |count, entry| + case count + when 1 then :one + else :other + end + }, + :ru => lambda { |count, entry| + case count % 100 + when 11,12,13,14 then :many + else case count % 10 + when 1 then :one + when 2,3,4 then :few + when 5,6,7,8,9,0 then :many + else :other + end + end + }, + :sl => lambda { |count, entry| + case count % 100 + when 1 then :one + when 2 then :two + when 3,4 then :few + else :other + end + } + } end # Overwrite this method to return something other than a String @@ -34,4 +61,4 @@ module Globalize end end end -end \ No newline at end of file +end