Skip to main content

Polish pluralization for Django templates.

Project description

Simple Django plugin providing pluralize_pl template filter that works similarly to Django’s built-in pluralize plugin but respects Polish grammar rules.

Quick start

  1. Install the plugin from PyPi:

    pip install django-pluralize-pl
    
  1. Add pluralize_pl to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'pluralize_pl',
    ]
    
  2. Load pluralize_pl in your templates:

    {% load pluralize_pl %}

  3. Use the pluralize_pl filter when you need it:

    {{ comments | pluralize_pl:”komentarz,komentarzy,komentarze” }}

Overview

pluralize_pl is fully compatible with Django’s pluralize filter. It works the same as long as you are giving it up to 2 comma-separated arguments. The difference is, you can provide it with a third argument, which will be used as a second plural form and applied according to Polish grammar rules:

  • If value is 0, {{ value|pluralize:"komentarz,komentarzy,komentarze" }} displays “komentarzy”.
  • If value is 1, {{ value|pluralize:"komentarz,komentarzy,komentarze" }} displays “komentarz”.
  • If value is 2, {{ value|pluralize:"komentarz,komentarzy,komentarze" }} displays “komentarze”.
  • If value is 5, {{ value|pluralize:"komentarz,komentarzy,komentarze" }} displays “komentarzy”.

Note that using the filter only makes sense if you do not utilize Django’s translation system, which already has built-in support for pluralization based on grammar rules of the target language.

Release history Release notifications

This version
History Node

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-pluralize-pl-0.2.tar.gz (3.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page