Skip to content

Commit

Permalink
Merge pull request #754 from pinewong/master
Browse files Browse the repository at this point in the history
Change pluralization rule for zh-* to Pluralization::OneOther rule.
  • Loading branch information
digitalfrost committed Jan 5, 2018
2 parents 7416877 + ef6fdcd commit 6437946
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions rails/pluralization/zh-CN.rb
@@ -1,3 +1,3 @@
require 'rails_i18n/common_pluralizations/other'
require 'rails_i18n/common_pluralizations/one_other'

::RailsI18n::Pluralization::Other.with_locale(:'zh-CN')
::RailsI18n::Pluralization::OneOther.with_locale(:'zh-CN')
4 changes: 2 additions & 2 deletions rails/pluralization/zh-HK.rb
@@ -1,3 +1,3 @@
require 'rails_i18n/common_pluralizations/other'
require 'rails_i18n/common_pluralizations/one_other'

::RailsI18n::Pluralization::Other.with_locale(:'zh-HK')
::RailsI18n::Pluralization::OneOther.with_locale(:'zh-HK')
4 changes: 2 additions & 2 deletions rails/pluralization/zh-TW.rb
@@ -1,3 +1,3 @@
require 'rails_i18n/common_pluralizations/other'
require 'rails_i18n/common_pluralizations/one_other'

::RailsI18n::Pluralization::Other.with_locale(:'zh-TW')
::RailsI18n::Pluralization::OneOther.with_locale(:'zh-TW')
4 changes: 2 additions & 2 deletions rails/pluralization/zh-YUE.rb
@@ -1,3 +1,3 @@
require 'rails_i18n/common_pluralizations/other'
require 'rails_i18n/common_pluralizations/one_other'

::RailsI18n::Pluralization::Other.with_locale(:'zh-YUE')
::RailsI18n::Pluralization::OneOther.with_locale(:'zh-YUE')
4 changes: 2 additions & 2 deletions rails/pluralization/zh.rb
@@ -1,3 +1,3 @@
require 'rails_i18n/common_pluralizations/other'
require 'rails_i18n/common_pluralizations/one_other'

::RailsI18n::Pluralization::Other.with_locale(:zh)
::RailsI18n::Pluralization::OneOther.with_locale(:zh)
16 changes: 16 additions & 0 deletions spec/unit/pluralization/one_other.rb
@@ -0,0 +1,16 @@
shared_examples 'one-other forms language' do
it 'has "one" and "other" plural keys' do
plural_keys.size.should == 2
plural_keys.should include(:one, :other)
end

it "detects that 1 in category 'one'" do
rule.call(1).should == :one
end

[0, 0.3, 1.2, 2, 3, 5, 10, 11, 21, 23, 31, 50, 81, 99, 100].each do |count|
it "detects that #{count} in category 'other'" do
rule.call(count).should == :other
end
end
end
3 changes: 2 additions & 1 deletion spec/unit/pluralization_spec.rb
Expand Up @@ -9,6 +9,7 @@

require 'unit/pluralization/ordinary'
require 'unit/pluralization/other'
require 'unit/pluralization/one_other'
require 'unit/pluralization/one_with_zero_other'
require 'unit/pluralization/one_upto_two_other'
require 'unit/pluralization/one_two_other'
Expand Down Expand Up @@ -175,7 +176,7 @@

describe 'Chinese', :locale => :zh do
it_behaves_like 'an ordinary pluralization rule'
it_behaves_like 'other form language'
it_behaves_like 'one-other forms language'
end

describe 'Colognian', :locale => :ksh do
Expand Down

0 comments on commit 6437946

Please sign in to comment.