Sha256: 2bf86935550c5071cce8e3b4896c06279042c83524ae65b16300b20840be35f8

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

module TwitterCldr
  module Formatters
    module Plurals
      class Rules
        class << self
          def all
            all_for(TwitterCldr::get_locale)
          end

          def all_for(locale)
            locale = TwitterCldr.convert_locale(locale.to_sym)
            get_resource(locale)[locale][:i18n][:plural][:keys]
          rescue => e
            []
          end

          def rule_for(number, locale = TwitterCldr::get_locale)
            locale = TwitterCldr.convert_locale(locale.to_sym)
            get_resource(locale)[locale][:i18n][:plural][:rule].call(number)
          rescue => e
            :other
          end

          protected

          def get_resource(locale)
            locale = TwitterCldr.convert_locale(locale)
            eval(TwitterCldr.resources.resource_for(locale, "plurals")[locale])
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr-1.0.0 lib/formatters/plurals/rules.rb