Sha256: 293fdf68fabcec3fe2f95f6e2f689e149c44aa839c944256bc8b81e492e41cf7

Contents?: true

Size: 802 Bytes

Versions: 12

Compression:

Stored size: 802 Bytes

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Js
    module Renderers
      module PluralRules

        class PluralRulesRenderer < TwitterCldr::Js::Renderers::Base
          self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../../..", "mustache/plurals/rules.coffee"))

          def rules
            ruby_str = TwitterCldr.get_locale_resource(@locale, :plurals)[@locale]
            rule_str = ruby_str.scan(/lambda\s*\{\s*\|n\|(.*?)\}/).first.first.strip
            js_str = PluralRulesCompiler.rule_to_js(rule_str)
            hash = eval(ruby_str)
            %Q({"keys": #{hash[@locale][:i18n][:plural][:keys].to_json}, "rule": #{js_str}})
          end
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
twitter_cldr_js-2.2.4 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr_js-2.2.3 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr_js-2.2.2 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr_js-2.2.0 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr_js-2.1.0 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr_js-2.0.0 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr_js-1.0.0 lib/twitter_cldr/js/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr-1.8.0 js/lib/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr-1.7.0 js/lib/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr-1.6.2 js/lib/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr-1.6.1 js/lib/renderers/plurals/rules/plural_rules_renderer.rb
twitter_cldr-1.6.0 js/lib/renderers/plurals/rules/plural_rules_renderer.rb