Django

Code

Changeset 973

Show
Ignore:
Timestamp:
10/20/05 02:36:44 (3 years ago)
Author:
hugo
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/i18n/django/utils/translation.py

    r964 r973  
    115115    global _translations 
    116116 
    117     if language == 'en' or language.startswith('en-'): 
    118         return gettext_module.NullTranslations() 
    119  
    120117    t = _translations.get(language, None) 
    121118    if t is not None: 
     
    291288        lang_code = request.GET.get('django_language', None) or request.POST.get('django_language', None) 
    292289        if lang_code is not None: 
    293             if lang_code == 'en' or lang_code.startswith('en-'): 
    294                 return lang_code 
    295290            lang = gettext_module.find('django', globalpath, [to_locale(lang_code)]) 
    296291            if lang is not None: 
     
    304299        lang_code = request.session.get('django_language', None) 
    305300        if lang_code is not None: 
    306             if lang_code == 'en' or lang_code.startswith('en-'): 
    307                 return lang_code 
    308301            lang = gettext_module.find('django', globalpath, [to_locale(lang_code)]) 
    309302            if lang is not None: 
     
    312305    lang_code = request.COOKIES.get('django_language', None) 
    313306    if lang_code is not None: 
    314         if lang_code == 'en' or lang_code.startswith('en-'): 
    315             return lang_code 
    316307        lang = gettext_module.find('django', globalpath, [to_locale(lang_code)]) 
    317308        if lang is not None: 
     
    342333 
    343334        for lang, order in langs: 
    344             if lang == 'en' or lang.startswith('en-'): 
    345                 # special casing for language en and derivates, because we don't 
    346                 # have an english language file available, but just fallback 
    347                 # to NullTranslation on those languages (as the source itself 
    348                 # is in english) 
     335            langfile = gettext_module.find('django', globalpath, [to_locale(lang)]) 
     336            if langfile: 
     337                # reconstruct the actual language from the language 
     338                # filename, because otherwise we might incorrectly 
     339                # report de_DE if we only have de available, but 
     340                # did find de_DE because of language normalization 
     341                lang = langfile[len(globalpath):].split('/')[1] 
    349342                _accepted[accept] = lang 
    350343                return lang 
    351             else: 
    352                 langfile = gettext_module.find('django', globalpath, [to_locale(lang)]) 
    353                 if langfile: 
    354                     # reconstruct the actual language from the language 
    355                     # filename, because otherwise we might incorrectly 
    356                     # report de_DE if we only have de available, but 
    357                     # did find de_DE because of language normalization 
    358                     lang = langfile[len(globalpath):].split('/')[1] 
    359                     _accepted[accept] = lang 
    360                     return lang 
    361344     
    362345    return settings.LANGUAGE_CODE