Module: RailsI18n::Pluralization::Arabic

Defined in:
lib/rails_i18n/pluralization.rb

Class Method Summary collapse

Class Method Details

.ruleObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails_i18n/pluralization.rb', line 4

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

    mod100 = n % 100

    if n == 0
      :zero
    elsif n == 1
      :one
    elsif n == 2
      :two
    elsif (3..10).to_a.include?(mod100)
      :few
    elsif (11..99).to_a.include?(mod100)
      :many
    else
      :other
    end
  end
end