Refs #2202 -- Cleaned up technique of splitting arguments, based upon a suggestion from SmileyChris.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b9d9351e85
commit
5ac919b711
|
@ -437,16 +437,13 @@ def pluralize(value, arg='s'):
|
||||||
is used instead. If the provided argument contains a comma, the text before
|
is used instead. If the provided argument contains a comma, the text before
|
||||||
the comma is used for the singular case.
|
the comma is used for the singular case.
|
||||||
"""
|
"""
|
||||||
|
if not ',' in arg:
|
||||||
|
arg = ',' + arg
|
||||||
bits = arg.split(',')
|
bits = arg.split(',')
|
||||||
if len(bits) == 2:
|
if len(bits) > 2:
|
||||||
singular_suffix = bits[0]
|
|
||||||
plural_suffix = bits[1]
|
|
||||||
elif len(bits) == 1:
|
|
||||||
singular_suffix = ''
|
|
||||||
plural_suffix = bits[0]
|
|
||||||
else:
|
|
||||||
return ''
|
return ''
|
||||||
|
singular_suffix, plural_suffix = bits[:2]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if int(value) != 1:
|
if int(value) != 1:
|
||||||
return plural_suffix
|
return plural_suffix
|
||||||
|
|
Loading…
Reference in New Issue