Opened 13 years ago

Closed 12 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 Łukasz Rekucki)

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()

@register.filter
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]

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

Change History (2)

comment:1 by Łukasz Rekucki, 13 years ago

Description: modified (diff)
Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

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 by Aymeric Augustin, 12 years ago

Resolution: wontfix
Status: newclosed

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