diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 4201cfe..526593d 100644
a
|
b
|
def filesizeformat(bytes):
|
839 | 839 | @register.filter(is_safe=False) |
840 | 840 | def pluralize(value, arg='s'): |
841 | 841 | """ |
842 | | Returns a plural suffix if the value is not 1. By default, 's' is used as |
843 | | the suffix: |
| 842 | Returns a singular suffix if the value is 1, '1' or an object of len 1, |
| 843 | plural suffix for different than 1, '1' or len != 1 and '' |
| 844 | if one cannot quantify the value in either singular or plural. |
| 845 | By default, 's' is used as the suffix: |
844 | 846 | |
845 | 847 | * If value is 0, vote{{ value|pluralize }} displays "0 votes". |
846 | 848 | * If value is 1, vote{{ value|pluralize }} displays "1 vote". |
… |
… |
def pluralize(value, arg='s'):
|
867 | 869 | return '' |
868 | 870 | singular_suffix, plural_suffix = bits[:2] |
869 | 871 | |
| 872 | if value == 1 or value == '1': |
| 873 | return singular_suffix |
870 | 874 | try: |
871 | | if int(value) != 1: |
872 | | return plural_suffix |
873 | | except ValueError: # Invalid string that's not a number. |
| 875 | float(value) |
| 876 | return plural_suffix |
| 877 | except ValueError: # String that cannot be converted to a numerical value |
874 | 878 | pass |
875 | | except TypeError: # Value isn't a string or a number; maybe it's a list? |
| 879 | except TypeError: # Value isn't a string nor a number; maybe it's a list? |
876 | 880 | try: |
877 | 881 | if len(value) != 1: |
878 | 882 | return plural_suffix |
879 | | except TypeError: # len() of unsized object. |
| 883 | else: |
| 884 | return singular_suffix |
| 885 | except TypeError: # Value is an unsized object |
880 | 886 | pass |
881 | | return singular_suffix |
| 887 | return '' |
882 | 888 | |
883 | 889 | @register.filter("phone2numeric", is_safe=True) |
884 | 890 | def phone2numeric_filter(value): |