jinja2_pluralize package¶
Module contents¶
-
jinja2_pluralize.
pluralize_dj
(value, arg='s')[source]¶ Adapted from django.template.defaultfilters: https://github.com/django/django/blob/master/django/template/defaultfilters.py
Returns a plural suffix if the value is not 1. By default, ‘s’ is used as the suffix:
- If value is 0, vote{{ value|pluralize }} displays “0 votes”.
- If value is 1, vote{{ value|pluralize }} displays “1 vote”.
- If value is 2, vote{{ value|pluralize }} displays “2 votes”.
If an argument is provided, that string is used instead:
- If value is 0, class{{ value|pluralize:”es” }} displays “0 classes”.
- If value is 1, class{{ value|pluralize:”es” }} displays “1 class”.
- If value is 2, class{{ value|pluralize:”es” }} displays “2 classes”.
If the provided argument contains a comma, the text before the comma is used for the singular case and the text after the comma is used for the plural case:
- If value is 0, cand{{ value|pluralize:”y,ies” }} displays “0 candies”.
- If value is 1, cand{{ value|pluralize:”y,ies” }} displays “1 candy”.
- If value is 2, cand{{ value|pluralize:”y,ies” }} displays “2 candies”.