Opened 13 years ago
Last modified 12 years ago
#17632 closed New feature
new filter for localflavor 'The Netherlands' — at Version 1
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 )
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 (1)
comment:1 by , 13 years ago
Description: | modified (diff) |
---|---|
Needs documentation: | set |
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
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.