Package pytils :: Package templatetags :: Module pytils_numeral
[hide private]

Module pytils_numeral

source code

pytils.numeral templatetags for Django web-framework

Functions [hide private]
 
choose_plural(amount, variants)
Choose proper form for plural.
source code
 
get_plural(amount, variants)
Get proper form for plural and it value.
source code
 
rubles(amount, zero_for_kopeck=False)
Converts float value to in-words representation (for money)
source code
 
in_words(amount, gender=None)
In-words representation of amount.
source code
 
sum_string(amount, gender, items)
in_words and choose_plural in a one flask Makes in-words representation of value with choosing correct form of noun.
source code
Variables [hide private]
  __revision__ = "$Id: pytils_numeral.py 102 2007-07-12 12:33:36...
  __id__ = "$Id: pytils_numeral.py 102 2007-07-12 12:33:36Z the....
  __url__ = "$URL: https://pythy.googlecode.com/svn/tags/pytils/...
  register = template.Library()
Django template tag/filter registrator
  encoding = conf.settings.DEFAULT_CHARSET
Current charset (sets in Django project's settings)
  debug = conf.settings.DEBUG
Debug mode (sets in Django project's settings)
  show_value = getattr(conf.settings, 'PYTILS_SHOW_VALUES_ON_ERR...
Show values on errors (sets in Django project's settings)
  default_value = ""
  default_uvalue = u""

Imports: django.template, django.conf, numeral, utils


Function Details [hide private]

choose_plural(amount, variants)

source code 

Choose proper form for plural.

Value is a amount, parameters are forms of noun. Forms are variants for 1, 2, 5 nouns. It may be tuple of elements, or string where variants separates each other by comma.

Examples:
   {{ some_int|choose_plural:"пример,примера,примеров" }}

get_plural(amount, variants)

source code 

Get proper form for plural and it value.

Value is a amount, parameters are forms of noun. Forms are variants for 1, 2, 5 nouns. It may be tuple of elements, or string where variants separates each other by comma. You can append 'absence variant' after all over variants

Examples:
   {{ some_int|get_plural:"пример,примера,примеров,нет примеров" }}

in_words(amount, gender=None)

source code 

In-words representation of amount.

Parameter is a gender: MALE, FEMALE or NEUTER

Examples:
   {{ some_int|in_words }}
   {{ some_other_int|in_words:FEMALE }}

sum_string(amount, gender, items)

source code 

in_words and choose_plural in a one flask Makes in-words representation of value with choosing correct form of noun.

First parameter is an amount of objects. Second is a gender (MALE, FEMALE, NEUTER). Third is a variants of forms for object name.

Examples:
   {% sum_string some_int MALE "пример,примера,примеров" %}
   {% sum_string some_other_int FEMALE "задача,задачи,задач" %}

Variables Details [hide private]

__revision__

Value:
"$Id: pytils_numeral.py 102 2007-07-12 12:33:36Z the.pythy $"

__id__

Value:
"$Id: pytils_numeral.py 102 2007-07-12 12:33:36Z the.pythy $"

__url__

Value:
"$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/templ\
atetags/pytils_numeral.py $"

show_value

Show values on errors (sets in Django project's settings)
Value:
getattr(conf.settings, 'PYTILS_SHOW_VALUES_ON_ERROR', False)