Sha256: 88c3d97af7d8f8aaa7d24c83b2018aa92c008d097f27431fb82e2aa0845df952

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

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
            []
          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
            :other
          end

          protected

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

Version data entries

1 entries across 1 versions & 1 rubygems

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