From 5ac919b71169772768eb3ac3c5506c8c31644e73 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 4 Jul 2006 06:31:26 +0000 Subject: [PATCH] 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 --- django/template/defaultfilters.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index 2b2a0d4568..5d56ec0c49 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -437,16 +437,13 @@ def pluralize(value, arg='s'): is used instead. If the provided argument contains a comma, the text before the comma is used for the singular case. """ + if not ',' in arg: + arg = ',' + arg bits = arg.split(',') - if len(bits) == 2: - singular_suffix = bits[0] - plural_suffix = bits[1] - elif len(bits) == 1: - singular_suffix = '' - plural_suffix = bits[0] - else: + if len(bits) > 2: return '' - + singular_suffix, plural_suffix = bits[:2] + try: if int(value) != 1: return plural_suffix