Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update Hebrew plural rule #219

Merged
merged 1 commit into from

2 participants

Andrii Malyshko Tsutomu Kuroda
Andrii Malyshko

This update goes in sync with changes Unicode.org made to Hebrew plural rule.

Tsutomu Kuroda kuroda merged commit 6af7e51 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 15, 2012
  1. Andrii Malyshko

    Update Hebrew plural rule

    nashbridges authored
This page is out of date. Refresh to see the latest.
Showing with 56 additions and 1 deletion.
  1. +25 −0 rails/pluralization/he.rb
  2. +31 −1 spec/unit/pluralization_spec.rb
25 rails/pluralization/he.rb
View
@@ -0,0 +1,25 @@
+module RailsI18n
+ module Pluralization
+ module Hebrew
+ def self.rule
+ lambda do |n|
+ if n == 1
+ :one
+ elsif n == 2
+ :two
+ elsif n != 0 && n % 10 == 0
+ :many
+ else
+ :other
+ end
+ end
+ end
+ end
+ end
+end
+
+{ :he => {
+ :i18n => {
+ :plural => {
+ :keys => [:one, :two, :many, :other],
+ :rule => RailsI18n::Pluralization::Hebrew.rule }}}}
32 spec/unit/pluralization_spec.rb
View
@@ -1,4 +1,4 @@
-# Implementation of http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
+# Implementation of http://unicode.org/cldr/trac/browser/trunk/common/supplemental/plurals.xml
# with additional specs for I18n pluralization data format.
#
# Locales that behave like English are omitted, because I18n applies English plural rule
@@ -247,6 +247,35 @@
it_behaves_like 'one(with zero)-other forms language'
end
+ describe 'Hebrew', :locale => :he do
+ it_behaves_like 'an ordinary pluralization rule'
+
+ it 'has "one", "two", "many" and "other" plural keys' do
+ plural_keys.size.should == 4
+ plural_keys.should include(:one, :two, :many, :other)
+ end
+
+ it "detects that 1 in category 'one'" do
+ rule.call(1).should == :one
+ end
+
+ it "detects that 2 in category 'two'" do
+ rule.call(2).should == :two
+ end
+
+ [10, 30, 70, 100, 130].each do |count|
+ it "detects that #{count} in category 'many'" do
+ rule.call(count).should == :many
+ end
+ end
+
+ [0, 1.2, 3.94, 8.2, 11, 12, 15, 19, 25, 27, 31, 52, 84, 99].each do |count|
+ it "detects that #{count} in category 'other'" do
+ rule.call(count).should == :other
+ end
+ end
+ end
+
describe 'Hindi', :locale => :hi do
it_behaves_like 'an ordinary pluralization rule'
it_behaves_like 'one(with zero)-other forms language'
@@ -554,6 +583,7 @@
it_behaves_like 'one(with zero)-other forms language'
end
+ # http://unicode.org/cldr/trac/ticket/4187
describe 'Persian', :locale => :fa do
it_behaves_like 'an ordinary pluralization rule'
it_behaves_like 'other form language'
Something went wrong with that request. Please try again.