mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +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:
parent
f29aab5447
commit
0ab4ae9349
@ -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,14 +332,6 @@ 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-'):
|
|
||||||
# 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)
|
|
||||||
_accepted[accept] = lang
|
|
||||||
return lang
|
|
||||||
else:
|
|
||||||
langfile = gettext_module.find('django', globalpath, [to_locale(lang)])
|
langfile = gettext_module.find('django', globalpath, [to_locale(lang)])
|
||||||
if langfile:
|
if langfile:
|
||||||
# reconstruct the actual language from the language
|
# reconstruct the actual language from the language
|
||||||
|
Loading…
x
Reference in New Issue
Block a user