Module: RailsI18n::Pluralization::Polish

Defined in:
lib/rails_i18n/pluralization.rb

Class Method Summary collapse

Class Method Details

.ruleObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/rails_i18n/pluralization.rb', line 108

def self.rule
  lambda do |n|
    return :other unless n.is_a?(Numeric)

    mod10 = n % 10
    mod100 = n % 100

    if n == 1
      :one
    elsif [2, 3, 4].include?(mod10) && ![12, 13, 14].include?(mod100)
      :few
    elsif [0, 1, 5, 6, 7, 8, 9].include?(mod10) || [12, 13, 14].include?(mod100)
      :many
    else
      :other
    end
  end
end