diff --git a/django/utils/translation.py b/django/utils/translation.py index 0737d9a0cd..6362a5923e 100644 --- a/django/utils/translation.py +++ b/django/utils/translation.py @@ -114,9 +114,6 @@ def translation(language): """ global _translations - if language == 'en' or language.startswith('en-'): - return gettext_module.NullTranslations() - t = _translations.get(language, None) if t is not None: return t @@ -290,8 +287,6 @@ def get_language_from_request(request): if request.GET or request.POST: lang_code = request.GET.get('django_language', None) or request.POST.get('django_language', None) if lang_code is not None: - if lang_code == 'en' or lang_code.startswith('en-'): - return lang_code lang = gettext_module.find('django', globalpath, [to_locale(lang_code)]) if lang is not None: if hasattr(request, 'session'): @@ -303,16 +298,12 @@ def get_language_from_request(request): if hasattr(request, 'session'): lang_code = request.session.get('django_language', None) if lang_code is not None: - if lang_code == 'en' or lang_code.startswith('en-'): - return lang_code lang = gettext_module.find('django', globalpath, [to_locale(lang_code)]) if lang is not None: return lang_code lang_code = request.COOKIES.get('django_language', None) if lang_code is not None: - if lang_code == 'en' or lang_code.startswith('en-'): - return lang_code lang = gettext_module.find('django', globalpath, [to_locale(lang_code)]) if lang is not None: return lang_code @@ -341,23 +332,15 @@ def get_language_from_request(request): langs.sort(lambda a,b: -1*cmp(a[1], b[1])) for lang, order in langs: - if lang == 'en' or lang.startswith('en-'): - # special casing for language en and derivates, because we don't - # have an english language file available, but just fallback - # to NullTranslation on those languages (as the source itself - # is in english) + langfile = gettext_module.find('django', globalpath, [to_locale(lang)]) + if langfile: + # reconstruct the actual language from the language + # filename, because otherwise we might incorrectly + # report de_DE if we only have de available, but + # did find de_DE because of language normalization + lang = langfile[len(globalpath):].split('/')[1] _accepted[accept] = lang return lang - else: - langfile = gettext_module.find('django', globalpath, [to_locale(lang)]) - if langfile: - # reconstruct the actual language from the language - # filename, because otherwise we might incorrectly - # report de_DE if we only have de available, but - # did find de_DE because of language normalization - lang = langfile[len(globalpath):].split('/')[1] - _accepted[accept] = lang - return lang return settings.LANGUAGE_CODE