Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#2202 closed enhancement (fixed)

[patch] Added optional argument to template filter "pluralize"

Reported by: gid <setre3+django@…> Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Makes the following valid in a template: {{ tomatoes|pluralize:"es" }}

Attachments (2)

optional_argument_to_pluralize_template_filter.diff (905 bytes ) - added by gid <setre3+django@…> 19 years ago.
optional_arguments_to_pluralize.patch (2.1 KB ) - added by Chris Beaven 18 years ago.
Pluralize with optional arguments (tests and documentation included)

Download all attachments as: .zip

Change History (10)

by gid <setre3+django@…>, 19 years ago

comment:1 by (none), 19 years ago

I dunno. The pluralize filter is a bad hack - it can't handle cases where the plural isn't formed by tacking something onto the end of the singular, e.g. man/men or knife/knives. There's a fair few of these cases in English, and it's the default in many languages.

AFAIK you can't pass more than one extra argument to a filter, so I don't think pluralize is fixable. If you care at all about grammatical correctness, you probably shouldn't be using it.

comment:2 by Adrian Holovaty, 19 years ago

The pluralize filter is a very simple 80% solution. This patch makes it more of an 85% solution, which I'm comfortable with. It just needs docs -- then it can be committed.

comment:3 by anonymous, 19 years ago

Owner: changed from Adrian Holovaty to anonymous
Status: newassigned

comment:4 by Adrian Holovaty, 19 years ago

Owner: changed from anonymous to Adrian Holovaty
Status: assignednew

comment:5 by Adrian Holovaty, 19 years ago

Status: newassigned

by Chris Beaven, 18 years ago

Pluralize with optional arguments (tests and documentation included)

comment:6 by Chris Beaven, 18 years ago

This patch allows for plural/singular alternatives too, so you can have your knife/knives.

comment:7 by Russell Keith-Magee, 18 years ago

Resolution: fixed
Status: assignedclosed

(In [3272]) Fixes #2202 -- Added ability to customize output of pluralize filter to handle irregular cases (walrus/walruses, cherry/cherries). Thanks to gid for the suggestion and the initial patch

comment:8 by Russell Keith-Magee, 18 years ago

(In [3273]) Refs #2202 -- Cleaned up technique of splitting arguments, based upon a suggestion from SmileyChris.

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