{"id":5976,"library":"jinja2-pluralize","title":"Jinja2 Pluralize Filters","description":"Jinja2 Pluralize is a Python library that provides pluralization filters for Jinja2 templates. It offers both a simple filter based on `inflect.py` and a Django-style pluralize filter. Currently at version 0.3.0, released in 2015, the project appears to be in a maintenance state with infrequent updates.","status":"maintenance","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/audreyr/jinja2_pluralize","tags":["Jinja2","filter","pluralize","Django","inflect","templates"],"install":[{"cmd":"pip install jinja2-pluralize","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core templating engine this library extends.","package":"Jinja2","optional":false},{"reason":"Required for the 'pluralize_simple' filter, but not a declared dependency.","package":"inflect","optional":true}],"imports":[{"note":"This is the Django-style pluralization filter, commonly used.","symbol":"pluralize_dj","correct":"from jinja2_pluralize import pluralize_dj"},{"note":"This is the simple pluralization filter, which depends on 'inflect'.","symbol":"pluralize_simple","correct":"from jinja2_pluralize import pluralize_simple"}],"quickstart":{"code":"from jinja2 import Environment\nfrom jinja2_pluralize import pluralize_dj\n\nenv = Environment()\nenv.filters['pluralize'] = pluralize_dj\n\ntemplate = env.from_string('I have {{ count }} dog{{ count|pluralize }}.')\n\n# Example 1: count = 1\nresult1 = template.render(count=1)\nprint(f\"Rendered for count=1: {result1}\") # Expected: I have 1 dog.\n\n# Example 2: count = 2\nresult2 = template.render(count=2)\nprint(f\"Rendered for count=2: {result2}\") # Expected: I have 2 dogs.\n\ntemplate_args = env.from_string('There {{ num_items|pluralize(\"is\", \"are\") }} {{ num_items }} item{{ num_items|pluralize }}.')\n\n# Example 3: using custom singular/plural words\nresult3 = template_args.render(num_items=1)\nprint(f\"Rendered for num_items=1: {result3}\") # Expected: There is 1 item.\n\nresult4 = template_args.render(num_items=3)\nprint(f\"Rendered for num_items=3: {result4}\") # Expected: There are 3 items.","lang":"python","description":"This quickstart demonstrates how to register the `pluralize_dj` filter with a Jinja2 environment and use it in a template to handle singular and plural forms of words, including custom plural suffixes."},"warnings":[{"fix":"Thoroughly test on your target Python and Jinja2 versions. Consider migrating to actively maintained alternatives for new projects or if issues arise.","message":"The library's last release was in 2015, and it was officially tested up to Python 3.5. While it might function on newer Python versions, active support and compatibility with recent Jinja2 releases (e.g., Jinja2 3.x) are not guaranteed, potentially leading to unforeseen issues.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Explicitly install `inflect` if you plan to use `pluralize_simple`.","message":"The `pluralize_simple` filter relies on the `inflect` library for its functionality. However, `inflect` is not a declared dependency of `jinja2-pluralize`. If you intend to use `pluralize_simple`, you must install `inflect` separately (`pip install inflect`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Evaluate `jinja2-inflection` or other actively maintained Jinja2 extensions for new projects or when upgrading existing ones.","message":"Given the lack of recent maintenance, consider modern and actively developed alternatives like `jinja2-inflection` for pluralization and other string transformations, which provides a broader set of filters and better compatibility with current Python and Jinja2 versions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}