Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #16909 -- Pass language to get_format_modules when calling it f…

…rom get_format to make sure the correct module is returned.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16884 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 66dc22c2d98c08a62588271507fd42bc7706541a 1 parent c59339f
@jezdez jezdez authored
Showing with 9 additions and 3 deletions.
  1. +4 −3 django/utils/formats.py
  2. +5 −0 tests/regressiontests/i18n/tests.py
View
7 django/utils/formats.py
@@ -45,11 +45,12 @@ def iter_format_modules(lang):
except ImportError:
pass
-def get_format_modules(reverse=False):
+def get_format_modules(lang=None, reverse=False):
"""
Returns a list of the format modules found
"""
- lang = get_language()
+ if lang is None:
+ lang = get_language()
modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang)))
if reverse:
return list(reversed(modules))
@@ -72,7 +73,7 @@ def get_format(format_type, lang=None, use_l10n=None):
try:
return _format_cache[cache_key] or getattr(settings, format_type)
except KeyError:
- for module in get_format_modules():
+ for module in get_format_modules(lang):
try:
val = getattr(module, format_type)
_format_cache[cache_key] = val
View
5 tests/regressiontests/i18n/tests.py
@@ -480,6 +480,11 @@ def test_iter_format_modules_stability(self):
en_gb_format_mod = import_module('django.conf.locale.en_GB.formats')
self.assertEqual(list(iter_format_modules('en-gb')), [en_gb_format_mod, en_format_mod])
+ def test_get_format_modules_lang(self):
+ with self.settings(USE_L10N=True):
+ with translation.override('de', deactivate=True):
+ self.assertEqual('.', get_format('DECIMAL_SEPARATOR', lang='en'))
+
def test_get_format_modules_stability(self):
with self.settings(USE_L10N=True,
FORMAT_MODULE_PATH='regressiontests.i18n.other.locale'):

0 comments on commit 66dc22c

Please sign in to comment.
Something went wrong with that request. Please try again.