Skip to content

Commit

Permalink
Added locale handling for currency filter
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardo-orozco committed Feb 19, 2014
1 parent bb4a3fb commit 2925d34
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion template_utils/templatetags/templateutils_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def currency(value, other_locale=None):
$13.00
"""
if type(value) in (int, float, Decimal):
locale.setlocale(locale.LC_ALL, '%s.utf8' % (other_locale or 'en_US'))
try:
locale.setlocale(locale.LC_ALL, '%s.utf8' % (other_locale or 'en_US'))
except locale.Error:
locale.setlocale(locale.LC_ALL, '%s.UTF-8' % (other_locale or 'en_US'))
return locale.currency(value, grouping=True)
return value

Expand Down

0 comments on commit 2925d34

Please sign in to comment.