fusionbox/django-fusionbox — pull request #29 by colinta (2012-04-05 18:01:01+00:00)
Title: pluralize_with filter

This filter uses the [`inflect`][inflect] module, which is a very thorough module indeed.

Usage:

```python
context = { 'num_cats': 1, 'num_dogs': 2, 'num_fish': 0, 'friends': ['rocky', 'gavin', 'chris', 'aaron', 'david'] }
```

```jinja

I have:

{{ num_cats|pluralize_with:"cat" }},

{{ num_dogs|pluralize_with:"dog" }},

{{ num_fish|pluralize_with:"fish" }}

and {{ friends|length|pluralize_with:"friend" }}

```

Outputs:

```html

I have:

1 cat,

2 dogs,

0 fish

and 5 friends

```

In the future, I would also like to add a filter for "none / one / some" (which `inflect` can do out of the box) and some grammar things like "there is" vs "there are".

[inflect]: http://pypi.python.org/pypi/inflect