Opened 14 years ago

Closed 11 years ago

#12380 closed Uncategorized (invalid)

Shouldn't the pluralize filter consider 0 to be singular?

Reported by: aleray Owned by: nobody
Component: Template system Version: 1.5
Severity: Normal Keywords: pluralize templatetag
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Shouldn't the pluralize filter consider 0 to be singular?

Consider this example:

{% get_comment_count for paragraph as comment_count %}
{{ comment_count }} comment{{ comment_count|pluralize }}

For instance if comment_count is equal to 0, the output will be "0 comments" (with a final s).

Change History (4)

comment:1 by anonymous, 14 years ago

comment:2 by Karen Tracey, 14 years ago

Resolution: invalid
Status: newclosed

No, in English zero uses the plural form, see:

http://en.wikipedia.org/wiki/Plural#Zero

The current behavior is correct and documented:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#pluralize

The only value that does not get the plural suffix is 1.

comment:3 by Etienne Desautels, 11 years ago

Component: Contrib appsTemplate system
Easy pickings: unset
Resolution: invalid
Severity: Normal
Status: closednew
Type: Uncategorized
UI/UX: unset
Version: 1.11.5

And what about other languages such as French where the plural form is not use for zero (see Wikipedia article)? Maybe pluralize should take into account the active language and do the right thing for each language? I know this is not simple.

comment:4 by Claude Paroz, 11 years ago

Resolution: invalid
Status: newclosed

I think that pluralize is mainly targeted to the English language. For any other language, you are probably better off creating your own specialized filter. You can then propose it as an external app or even as part of a localflavor.

Please discuss it on django-dev first, and if a real solution emerges, then reopen the ticket.

Note: See TracTickets for help on using tickets.
Back to Top