1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix pluralization for numbers formatted like '1.00'

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
Gabriel Mansour 2010-01-30 12:38:33 -05:00 committed by Jeremy Kemper
parent a1a6e54d14
commit b235af702a
2 changed files with 3 additions and 1 deletions

View file

@ -187,7 +187,7 @@ module ActionView
# pluralize(0, 'person')
# # => 0 people
def pluralize(count, singular, plural = nil)
"#{count || 0} " + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))
"#{count || 0} " + ((count == 1 || count =~ /^1(\.0+)?$/) ? singular : (plural || singular.pluralize))
end
# Wraps the +text+ into lines no longer than +line_width+ width. This method

View file

@ -228,6 +228,8 @@ class TextHelperTest < ActionView::TestCase
assert_equal("2 counts", pluralize('2', "count"))
assert_equal("1,066 counts", pluralize('1,066', "count"))
assert_equal("1.25 counts", pluralize('1.25', "count"))
assert_equal("1.0 count", pluralize('1.0', "count"))
assert_equal("1.00 count", pluralize('1.00', "count"))
assert_equal("2 counters", pluralize(2, "count", "counters"))
assert_equal("0 counters", pluralize(nil, "count", "counters"))
assert_equal("2 people", pluralize(2, "person"))