import lfc.utils
from django.conf import settings
from django.utils import translation

def main(request):
    """context processor for LFC.
    """
    current_language = translation.get_language()
    default_language = settings.LANGUAGE_CODE

    return {
        "PORTAL" : lfc.utils.get_portal(),
        "LFC_MULTILANGUAGE"   : settings.LFC_MULTILANGUAGE,
        "DEFAULT_LANGUAGE"    : default_language,
        "CURRENT_LANGUAGE"    : current_language,
        "IS_DEFAULT_LANGUAGE" : default_language == current_language,
    }

import lfc.utils
from django.conf import settings
from django.utils import translation

def main(request):
    """context processor for LFC.
    """
    current_language = translation.get_language()
    default_language = settings.LANGUAGE_CODE
    
    is_default_language = default_language == current_language
    if current_language == "0" or is_default_language:
        link_language = ""
    else:
        link_language = current_language
    
    return {
        "PORTAL" : lfc.utils.get_portal(),
        "LFC_MULTILANGUAGE"   : settings.LFC_MULTILANGUAGE,
        "DEFAULT_LANGUAGE"    : default_language,
        "CURRENT_LANGUAGE"    : current_language,
        "IS_DEFAULT_LANGUAGE" : is_default_language,
        "LINK_LANGUAGE"       : link_language, 
    }

Return correct language for using within links
Improvement: Return correct language for using within links

  import lfc.utils
  from django.conf import settings
  from django.utils import translation
  
  def main(request):
      """context processor for LFC.
      """
      current_language = translation.get_language()
      default_language = settings.LANGUAGE_CODE
- 
+     
+     is_default_language = default_language == current_language
+     if current_language == "0" or is_default_language:
+         link_language = ""
+     else:
+         link_language = current_language
+     
      return {
          "PORTAL" : lfc.utils.get_portal(),
          "LFC_MULTILANGUAGE"   : settings.LFC_MULTILANGUAGE,
          "DEFAULT_LANGUAGE"    : default_language,
          "CURRENT_LANGUAGE"    : current_language,
-         "IS_DEFAULT_LANGUAGE" : default_language == current_language,
+         "IS_DEFAULT_LANGUAGE" : is_default_language,
+         "LINK_LANGUAGE"       : link_language, 
      }
  
Return correct language for using within links
## Code Before:
import lfc.utils
from django.conf import settings
from django.utils import translation

def main(request):
    """context processor for LFC.
    """
    current_language = translation.get_language()
    default_language = settings.LANGUAGE_CODE

    return {
        "PORTAL" : lfc.utils.get_portal(),
        "LFC_MULTILANGUAGE"   : settings.LFC_MULTILANGUAGE,
        "DEFAULT_LANGUAGE"    : default_language,
        "CURRENT_LANGUAGE"    : current_language,
        "IS_DEFAULT_LANGUAGE" : default_language == current_language,
    }

## Instruction:
Return correct language for using within links
## Code After:
import lfc.utils
from django.conf import settings
from django.utils import translation

def main(request):
    """context processor for LFC.
    """
    current_language = translation.get_language()
    default_language = settings.LANGUAGE_CODE
    
    is_default_language = default_language == current_language
    if current_language == "0" or is_default_language:
        link_language = ""
    else:
        link_language = current_language
    
    return {
        "PORTAL" : lfc.utils.get_portal(),
        "LFC_MULTILANGUAGE"   : settings.LFC_MULTILANGUAGE,
        "DEFAULT_LANGUAGE"    : default_language,
        "CURRENT_LANGUAGE"    : current_language,
        "IS_DEFAULT_LANGUAGE" : is_default_language,
        "LINK_LANGUAGE"       : link_language, 
    }
