Module: RailsI18n::Pluralization::Romanian

Defined in:
lib/rails_i18n/common_pluralizations/romanian.rb

Constant Summary collapse

FROM_1_TO_19 =
(1..19).to_a.freeze

Class Method Summary collapse

Class Method Details

.ruleObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_i18n/common_pluralizations/romanian.rb', line 8

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

    if n == 1
      :one
    elsif n == 0 || FROM_1_TO_19.include?(n % 100)
      :few
    else
      :other
    end
  end
end

.with_locale(locale) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rails_i18n/common_pluralizations/romanian.rb', line 22

def self.with_locale(locale)
  { locale => {
      :'i18n' => {
        :plural => {
          :keys => [:one, :few, :other],
          :rule => rule }}}}
end