Skip to content

Commit

Permalink
handle double pluralization for irregular plurals
Browse files Browse the repository at this point in the history
[#6363]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
Dan Pickett authored and spastorino committed Feb 16, 2011
1 parent 0cee303 commit e925acb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions activesupport/lib/active_support/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ module ActiveSupport
inflect.plural(/s$/i, 's')
inflect.plural(/(ax|test)is$/i, '\1es')
inflect.plural(/(octop|vir)us$/i, '\1i')
inflect.plural(/(octop|vir)i$/i, '\1i')
inflect.plural(/(alias|status)$/i, '\1es')
inflect.plural(/(bu)s$/i, '\1ses')
inflect.plural(/(buffal|tomat)o$/i, '\1oes')
inflect.plural(/([ti])um$/i, '\1a')
inflect.plural(/([ti])a$/i, '\1a')
inflect.plural(/sis$/i, 'ses')
inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
inflect.plural(/(hive)$/i, '\1s')
inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
inflect.plural(/([m|l])ouse$/i, '\1ice')
inflect.plural(/([m|l])ice$/i, '\1ice')
inflect.plural(/^(ox)$/i, '\1en')
inflect.plural(/^(oxen)$/i, '\1')
inflect.plural(/(quiz)$/i, '\1zes')

inflect.singular(/s$/i, '')
Expand Down
7 changes: 7 additions & 0 deletions activesupport/test/inflector_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def test_uncountable_word_is_not_greedy
assert_equal(singular.capitalize, ActiveSupport::Inflector.singularize(plural.capitalize))
end
end

SingularToPlural.each do |singular, plural|
define_method "test_pluralize_#{plural}" do
assert_equal(plural, ActiveSupport::Inflector.pluralize(plural))
assert_equal(plural.capitalize, ActiveSupport::Inflector.pluralize(plural.capitalize))
end
end

def test_overwrite_previous_inflectors
assert_equal("series", ActiveSupport::Inflector.singularize("series"))
Expand Down
1 change: 1 addition & 0 deletions activesupport/test/inflector_test_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module InflectorTestCases

"datum" => "data",
"medium" => "media",
"stadium" => "stadia",
"analysis" => "analyses",

"node_child" => "node_children",
Expand Down

0 comments on commit e925acb

Please sign in to comment.