1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

i18n: removed special casing for en and en-* - we now have an english translation file, so just handle en the same way as other languages

git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@973 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Georg Bauer 2005-10-20 07:36:44 +00:00
parent f29aab5447
commit 0ab4ae9349

View File

@ -114,9 +114,6 @@ def translation(language):
""" """
global _translations global _translations
if language == 'en' or language.startswith('en-'):
return gettext_module.NullTranslations()
t = _translations.get(language, None) t = _translations.get(language, None)
if t is not None: if t is not None:
return t return t
@ -290,8 +287,6 @@ def get_language_from_request(request):
if request.GET or request.POST: if request.GET or request.POST:
lang_code = request.GET.get('django_language', None) or request.POST.get('django_language', None) lang_code = request.GET.get('django_language', None) or request.POST.get('django_language', None)
if lang_code is not 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)]) lang = gettext_module.find('django', globalpath, [to_locale(lang_code)])
if lang is not None: if lang is not None:
if hasattr(request, 'session'): if hasattr(request, 'session'):
@ -303,16 +298,12 @@ def get_language_from_request(request):
if hasattr(request, 'session'): if hasattr(request, 'session'):
lang_code = request.session.get('django_language', None) lang_code = request.session.get('django_language', None)
if lang_code is not 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)]) lang = gettext_module.find('django', globalpath, [to_locale(lang_code)])
if lang is not None: if lang is not None:
return lang_code return lang_code
lang_code = request.COOKIES.get('django_language', None) lang_code = request.COOKIES.get('django_language', None)
if lang_code is not 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)]) lang = gettext_module.find('django', globalpath, [to_locale(lang_code)])
if lang is not None: if lang is not None:
return lang_code return lang_code
@ -341,23 +332,15 @@ def get_language_from_request(request):
langs.sort(lambda a,b: -1*cmp(a[1], b[1])) langs.sort(lambda a,b: -1*cmp(a[1], b[1]))
for lang, order in langs: for lang, order in langs:
if lang == 'en' or lang.startswith('en-'): langfile = gettext_module.find('django', globalpath, [to_locale(lang)])
# special casing for language en and derivates, because we don't if langfile:
# have an english language file available, but just fallback # reconstruct the actual language from the language
# to NullTranslation on those languages (as the source itself # filename, because otherwise we might incorrectly
# is in english) # 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 _accepted[accept] = lang
return 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 return settings.LANGUAGE_CODE