@register.filter
def currency(value):
 set_locale()
 if (not value):
  value = 0
 value = locale.currency(Decimal(value), grouping=True)
 if (platform.system() == u'Windows'):
  try:
   value = str(value, encoding=locale.getpreferredencoding())
  except TypeError:
   pass
 return value

@ register . filter def currency ( value ) : set_locale ( ) if ( not value ) : value = 0 value = locale . currency ( Decimal ( value ) , grouping = True ) if ( platform . system ( ) == u'Windows' ) : try : value = str ( value , encoding = locale . getpreferredencoding ( ) ) except TypeError : pass return value
format a value as currency according to locale .