Django

Code

Ticket #2202 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: gid <setre3+django@gmail.com> Assigned to: adrian
Milestone: Component: Template system
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

Attachments

optional_argument_to_pluralize_template_filter.diff (0.9 kB) - added by gid <setre3+django@gmail.com> on 06/20/06 03:15:48.
optional_arguments_to_pluralize.patch (2.1 kB) - added by SmileyChris on 07/04/06 00:41:54.
Pluralize with optional arguments (tests and documentation included)

Change History

06/20/06 03:15:48 changed by gid <setre3+django@gmail.com>

  • attachment optional_argument_to_pluralize_template_filter.diff added.

06/20/06 08:03:44 changed by

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.

06/20/06 08:26:02 changed by adrian

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.

06/21/06 09:44:32 changed by anonymous

  • owner changed from adrian to anonymous.
  • status changed from new to assigned.

06/21/06 09:45:05 changed by adrian

  • owner changed from anonymous to adrian.
  • status changed from assigned to new.

06/21/06 09:46:15 changed by adrian

  • status changed from new to assigned.

07/04/06 00:41:54 changed by SmileyChris

  • attachment optional_arguments_to_pluralize.patch added.

Pluralize with optional arguments (tests and documentation included)

07/04/06 00:45:26 changed by SmileyChris

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

07/04/06 01:18:39 changed by russellm

  • status changed from assigned to closed.
  • resolution set to fixed.

(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

07/04/06 01:31:26 changed by russellm

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


Add/Change #2202 ([patch] Added optional argument to template filter "pluralize")




Change Properties
Action