Ticket #19763: django_utils_translation_trans_real.py.diff

File django_utils_translation_trans_real.py.diff, 614 bytes (added by Emanuel Steen, 12 years ago)

Patch for checking for supported languages when using settings.LANGUAGE_CODE

  • utils/translation/trans_real.py

    old new  
    427427                    _accepted[normalized] = lang
    428428                    return lang
    429429
     430    lang_code = settings.LANGUAGE_CODE
     431
     432    if lang_code and lang_code not in supported:
     433        lang_code = lang_code.split('-')[0] # e.g. if fr-ca is not supported fallback to fr
     434
     435    if lang_code and lang_code in supported and check_for_language(lang_code):
     436        return lang_code
     437
    430438    return settings.LANGUAGE_CODE
    431439
    432440dot_re = re.compile(r'\S')
Back to Top