

def get_language_from_request(request, current_page=None):
    '\n    Return the most obvious language according the request\n    '
    language = None
    if hasattr(request, 'POST'):
        language = request.POST.get('language', None)
    if (hasattr(request, 'GET') and (not language)):
        language = request.GET.get('language', None)
    site_id = (current_page.site_id if current_page else None)
    if language:
        language = get_language_code(language)
        if (not (language in get_language_list(site_id))):
            language = None
    if (language is None):
        language = get_language_code(getattr(request, 'LANGUAGE_CODE', None))
    if language:
        if (not (language in get_language_list(site_id))):
            language = None
    if ((language is None) and current_page):
        languages = current_page.get_languages()
        if (len(languages) > 0):
            language = languages[0]
    if (language is None):
        language = get_default_language(site_id=site_id)
    return language

dataset/ETHPy150Open divio/django-cms/cms/utils/__init__.py get_language_from_request/original