From ac59ec8f1a34ea0e82bdb3c77422694e8016e0a7 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 11 May 2018 15:59:31 +0430 Subject: [PATCH] Aliased trans_null.to_locale() to trans_real.to_locale(). The implementations have unintentionally diverged. --- django/utils/translation/trans_null.py | 9 +++------ tests/i18n/tests.py | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py index 3eb6910f04..5cda498336 100644 --- a/django/utils/translation/trans_null.py +++ b/django/utils/translation/trans_null.py @@ -4,6 +4,8 @@ from django.conf import settings +from .trans_real import to_locale as trans_real_to_locale + def gettext(message): return message @@ -52,12 +54,7 @@ def check_for_language(x): return True -def to_locale(language): - p = language.find('-') - if p >= 0: - return language[:p].lower() + '_' + language[p + 1:].upper() - else: - return language.lower() +to_locale = trans_real_to_locale def get_language_from_request(request, check_path=False): diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index ae002dcff1..6ad7752d85 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -286,6 +286,7 @@ class TranslationTests(SimpleTestCase): for lang, locale in tests: with self.subTest(lang=lang): self.assertEqual(to_locale(lang), locale) + self.assertEqual(trans_null.to_locale(lang), locale) def test_to_language(self): self.assertEqual(trans_real.to_language('en_US'), 'en-us')