Skip to content

Commit 5ac919b

Browse files
committed
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
1 parent b9d9351 commit 5ac919b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

django/template/defaultfilters.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,13 @@ def pluralize(value, arg='s'):
437437
is used instead. If the provided argument contains a comma, the text before
438438
the comma is used for the singular case.
439439
"""
440+
if not ',' in arg:
441+
arg = ',' + arg
440442
bits = arg.split(',')
441-
if len(bits) == 2:
442-
singular_suffix = bits[0]
443-
plural_suffix = bits[1]
444-
elif len(bits) == 1:
445-
singular_suffix = ''
446-
plural_suffix = bits[0]
447-
else:
443+
if len(bits) > 2:
448444
return ''
449-
445+
singular_suffix, plural_suffix = bits[:2]
446+
450447
try:
451448
if int(value) != 1:
452449
return plural_suffix

0 commit comments

Comments
 (0)