      as the provided language codes are taken from the HTTP request. See also
      <https://www.djangoproject.com/weblog/2007/oct/26/security-fix/>.
      """
      # First, a quick check to make sure lang_code is well-formed (#21458)
      if not language_code_re.search(lang_code):
          return False
      for path in all_locale_paths():
          if gettext_module.find('django', path, [to_locale(lang_code)]) is not None:
              return True
      return False
 
</s> remove     base_lang = get_language().split('-')[0]
    return base_lang in settings.LANGUAGES_BIDI
 </s> add     lang = get_language()
    if lang is None:
        return False
    else:
        base_lang = get_language().split('-')[0]
        return base_lang in settings.LANGUAGES_BIDI </s> remove     get_language, get_language_from_request, get_language_info, gettext,
    gettext_lazy, ngettext_lazy, npgettext, npgettext_lazy, pgettext,
    pgettext_lazy, string_concat, to_locale, trans_real, ugettext,
    ugettext_lazy, ungettext, ungettext_lazy,
 </s> add     get_language, get_language_bidi, get_language_from_request,
    get_language_info, gettext, gettext_lazy, ngettext_lazy, npgettext,
    npgettext_lazy, pgettext, pgettext_lazy, string_concat, to_locale,
    trans_real, ugettext, ugettext_lazy, ungettext, ungettext_lazy,
    if lang_code is None or not language_code_re.search(lang_code):
      as the provided language codes are taken from the HTTP request. See also
      <https://www.djangoproject.com/weblog/2007/oct/26/security-fix/>.
      """
      # First, a quick check to make sure lang_code is well-formed (#21458)
    if lang_code is None or not language_code_re.search(lang_code):
          return False
      for path in all_locale_paths():
          if gettext_module.find('django', path, [to_locale(lang_code)]) is not None:
              return True
      return False
keep keep keep keep replace keep keep keep keep keep
 Fixed #24569 -- Made some translation functions accept None value

get_language() can return None when translations are deactivated.
Thanks Nicola Peduzzi for the reporti and Tim Graham for the review. 
django/utils/translation/trans_real.py