Opened 4 years ago

Closed 4 years ago

#17632 closed New feature (wontfix)

new filter for localflavor 'The Netherlands'

Reported by: lkeijser Owned by: nobody
Component: contrib.localflavor Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by lrekucki)

I've created a small filter that can be used in the same way as 'pluralize'. It basically adds 'en' (most common pluralized word in Dutch) when used.

from django import template
from django.template.defaultfilters import stringfilter

register = template.Library()

def meervoud(value, arg=u'en'):
    if not u',' in arg:
        arg = u',' + arg
    bits = arg.split(u',')
    if len(bits) > 2:
        return u''
    singular_suffix, plural_suffix = bits[:2]

        if int(value) != 1:
            return plural_suffix
    except ValueError: # Invalid string that's not a number.
    except TypeError: # Value isn't a string or a number; maybe it's a list?
            if len(value) != 1:
                return plural_suffix
        except TypeError: # len() of unsized object.
    return singular_suffix

Change History (2)

comment:1 Changed 4 years ago by lrekucki

  • Description modified (diff)
  • Needs documentation set
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Please provide this in a form of a patch (diff against current Django trunk) attached to the ticket. Also, every new feature needs both tests and documentation. I'm not Dutch so I can't really speak about usefulness of this.

comment:2 Changed 4 years ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

Thanks for the proposal, but I'd prefer not to include this in Django:

  • Pluralization rules are notoriously hard to get right in general, and Dutch is no exception (pun intended). A pluralization filter is a promise we won't be able to keep.
  • No other local flavor ships template filters.
Note: See TracTickets for help on using tickets.
Back to Top