Opened 15 years ago
Closed 12 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 , 15 years ago
comment:2 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Component: | Contrib apps → Template system |
---|---|
Easy pickings: | unset |
Resolution: | invalid |
Severity: | → Normal |
Status: | closed → new |
Type: | → Uncategorized |
UI/UX: | unset |
Version: | 1.1 → 1.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 , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
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.