summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-05-12 15:03:38 -0400
committerGitHub <noreply@github.com>2018-05-12 15:03:38 -0400
commit1e0cbc72e5bcb1c1e235b3cd82a92800ed3c84b8 (patch)
treeca7ed11aa734fd9e7288f2b1c91f45d038f4514c /django
parent35319bf12ccefe1911588493484160aa49208f89 (diff)
downloaddjango-1e0cbc72e5bcb1c1e235b3cd82a92800ed3c84b8.tar.gz
Moved to_language() to django.utils.translation.
Follow up to 1b7d524cfa7b7834af26c99407af66be6813938d.
Diffstat (limited to 'django')
-rw-r--r--django/utils/translation/__init__.py11
-rw-r--r--django/utils/translation/trans_real.py11
2 files changed, 11 insertions, 11 deletions
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 1788e82878..28ab9c015f 100644
--- a/django/utils/translation/__init__.py
+++ b/django/utils/translation/__init__.py
@@ -10,7 +10,7 @@ __all__ = [
'activate', 'deactivate', 'override', 'deactivate_all',
'get_language', 'get_language_from_request',
'get_language_info', 'get_language_bidi',
- 'check_for_language', 'to_locale', 'templatize',
+ 'check_for_language', 'to_language', 'to_locale', 'templatize',
'gettext', 'gettext_lazy', 'gettext_noop',
'ugettext', 'ugettext_lazy', 'ugettext_noop',
'ngettext', 'ngettext_lazy',
@@ -193,6 +193,15 @@ def check_for_language(lang_code):
return _trans.check_for_language(lang_code)
+def to_language(locale):
+ """Turn a locale name (en_US) into a language name (en-us)."""
+ p = locale.find('_')
+ if p >= 0:
+ return locale[:p].lower() + '-' + locale[p + 1:].lower()
+ else:
+ return locale.lower()
+
+
def to_locale(language):
"""Turn a language name (en-us) into a locale name (en_US)."""
language = language.lower()
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 14e9e046a6..266843aa1d 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -16,7 +16,7 @@ from django.core.signals import setting_changed
from django.dispatch import receiver
from django.utils.safestring import SafeData, mark_safe
-from . import LANGUAGE_SESSION_KEY, to_locale
+from . import LANGUAGE_SESSION_KEY, to_language, to_locale
# Translations are cached in a dictionary for every language.
# The active translations are stored by threadid to make them thread local.
@@ -57,15 +57,6 @@ def reset_cache(**kwargs):
get_supported_language_variant.cache_clear()
-def to_language(locale):
- """Turn a locale name (en_US) into a language name (en-us)."""
- p = locale.find('_')
- if p >= 0:
- return locale[:p].lower() + '-' + locale[p + 1:].lower()
- else:
- return locale.lower()
-
-
class DjangoTranslation(gettext_module.GNUTranslations):
"""
Set up the GNUTranslations context with regard to output charset.