Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #15024 -- Ensure that choice of L10N format module used is stab…

…le given a stable setup of format modules in ll/ and ll_CC/ dirs. Thanks David Reynolds for the report and suggestions leading to the solution.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15183 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fd12e3b2186e47653b25efccec28cee68bd20f7e 1 parent 1c56af6
@ramiro ramiro authored
Showing with 16 additions and 1 deletion.
  1. +3 −1 django/utils/formats.py
  2. +13 −0 tests/regressiontests/i18n/tests.py
View
4 django/utils/formats.py
@@ -24,7 +24,9 @@ def iter_format_modules(lang):
format_locations.append(settings.FORMAT_MODULE_PATH + '.%s')
format_locations.reverse()
locale = to_locale(lang)
- locales = set((locale, locale.split('_')[0]))
+ locales = [locale]
+ if '_' in locale:
+ locales.append(locale.split('_')[0])
for location in format_locations:
for loc in locales:
try:
View
13 tests/regressiontests/i18n/tests.py
@@ -480,6 +480,19 @@ def test_iter_format_modules(self):
settings.FORMAT_MODULE_PATH = old_format_module_path
deactivate()
+ def test_iter_format_modules_stability(self):
+ """
+ Tests the iter_format_modules function always yields format modules in
+ a stable and correct order in presence of both base ll and ll_CC formats.
+ """
+ try:
+ old_l10n, settings.USE_L10N = settings.USE_L10N, True
+ en_format_mod = import_module('django.conf.locale.en.formats')
+ 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])
+ finally:
+ settings.USE_L10N = old_l10n
+
def test_localize_templatetag_and_filter(self):
"""
Tests the {% localize %} templatetag

0 comments on commit fd12e3b

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