Module: Worldwide::Plurals

Extended by:
Plurals
Included in:
Plurals
Defined in:
lib/worldwide/plurals.rb

Defined Under Namespace

Classes: UnknownLocaleError, UnknownPluralizationTypeError

Instance Method Summary collapse

Instance Method Details

#all_cardinal_pluralization_keysObject

START OF AUTO-GENERATED CONTENT Do not hand-edit this section. It is auto-generated by rake/cldr/locale_generator.rb



28
29
30
# File 'lib/worldwide/plurals.rb', line 28

def all_cardinal_pluralization_keys
  [:few, :many, :one, :other, :two, :zero].freeze
end

#all_ordinal_pluralization_keysObject



32
33
34
# File 'lib/worldwide/plurals.rb', line 32

def all_ordinal_pluralization_keys
  [:few, :many, :one, :other, :two, :zero].freeze
end

#keys(locale, type: :cardinal) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/worldwide/plurals.rb', line 11

def keys(locale, type: :cardinal)
  return [:other] if locale == :root

  case type
  when :cardinal
    cardinal_pluralization_keys.fetch(locale.to_sym)
  when :ordinal
    ordinal_pluralization_keys.fetch(locale.to_sym)
  else
    raise UnknownPluralizationTypeError, "Unknown pluralization type: `#{type}`. Valid values are :cardinal or :ordinal"
  end
rescue KeyError
  raise UnknownLocaleError, "Unknown locale code: `#{locale}`."
end