Skip to content

Commit

Permalink
Fixed #12435 - Handle Unicode characters in format strings correctly.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12057 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jezdez committed Jan 1, 2010
1 parent 855e805 commit ac371cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions django/utils/formats.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_format(format_type):
language (locale), defaults to the format in the settings. language (locale), defaults to the format in the settings.
format_type is the name of the format, e.g. 'DATE_FORMAT' format_type is the name of the format, e.g. 'DATE_FORMAT'
""" """
format_type = smart_str(format_type)
if settings.USE_L10N: if settings.USE_L10N:
for module in get_format_modules(): for module in get_format_modules():
try: try:
Expand Down
5 changes: 5 additions & 0 deletions tests/regressiontests/i18n/tests.py
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
import sys import sys
import decimal import decimal
import datetime import datetime
Expand Down Expand Up @@ -138,6 +139,10 @@ def test_locale_independent(self):
self.assertEqual(u'-66666.6', format(-66666.666, decimal_sep='.', decimal_pos=1)) self.assertEqual(u'-66666.6', format(-66666.666, decimal_sep='.', decimal_pos=1))
self.assertEqual(u'-66666.0', format(int('-66666'), decimal_sep='.', decimal_pos=1)) self.assertEqual(u'-66666.0', format(int('-66666'), decimal_sep='.', decimal_pos=1))


# date filter
self.assertEqual(u'31.12.2009 в 20:50', Template('{{ dt|date:"d.m.Y в H:i" }}').render(self.ctxt))
self.assertEqual(u'⌚ 10:15', Template('{{ t|time:"⌚ H:i" }}').render(self.ctxt))

def test_l10n_disabled(self): def test_l10n_disabled(self):
""" """
Catalan locale with format i18n disabled translations will be used, Catalan locale with format i18n disabled translations will be used,
Expand Down

0 comments on commit ac371cc

Please sign in to comment.