Return to Snippet

Revision: 17552
at September 9, 2009 11:40 by vas3k


Initial Code
# -*- coding: utf-8 -*-
from django import template

register = template.Library()

@register.filter
def rupluralize(value, arg="дурак,дурака,дураков"):
    	args = arg.split(",")
        if not value:
		return args[2]
	number = abs(int(value))
        a = number % 10
        b = number % 100

        if (a == 1) and (b != 11):
            return args[0]
        elif (a > 1) and (a < 5) and ((b < 10) or (b > 20)):
            return args[1]
        else:
            return args[2]

Initial URL

                                

Initial Description

                                

Initial Title
Django: Pluralize templatetag for Russian lang

Initial Tags
python, django

Initial Language
Python