<s> """<STR_LIT>""" <EOL> from django . conf import settings <EOL> from parler import appsettings <EOL> from parler . utils import normalize_language_code , is_multilingual_project , get_language_title <EOL> def get_language_parameter ( request , query_language_key = '<STR_LIT>' , object = None , default = None ) : <EOL> """<STR_LIT>""" <EOL> if not is_multilingual_project ( ) : <EOL> return default or appsettings . PARLER_LANGUAGES . get_default_language ( ) <EOL> else : <EOL> code = request . GET . get ( query_language_key ) <EOL> if not code : <EOL> code = default or appsettings . PARLER_LANGUAGES . get_first_language ( ) <EOL> return normalize_language_code ( code ) <EOL> def get_language_tabs ( request , current_language , available_languages , css_class = None ) : <EOL> """<STR_LIT>""" <EOL> tabs = TabsList ( css_class = css_class ) <EOL> get = request . GET . copy ( ) <EOL> tab_languages = [ ] <EOL> site_id = getattr ( settings , '<STR_LIT>' , None ) <EOL> for lang_dict in appsettings . PARLER_LANGUAGES . get ( site_id , ( ) ) : <EOL> code = lang_dict [ '<STR_LIT:code>' ] <EOL> title = get_language_title ( code ) <EOL> get [ '<STR_LIT>' ] = code <EOL> url = '<STR_LIT>' . format ( get . urlencode ( ) ) <EOL> if code == current_language : <EOL> status = '<STR_LIT>' <EOL> elif code in available_languages : <EOL> status = '<STR_LIT>' <EOL> else : <EOL> status = '<STR_LIT>' <EOL> tabs . append ( ( url , title , code , status ) ) <EOL> tab_languages . append ( code ) <EOL> if appsettings . PARLER_SHOW_EXCLUDED_LANGUAGE_TABS : <EOL> for code in available_languages : <EOL> if code not in tab_languages : <EOL> get [ '<STR_LIT>' ] = code <EOL> url = '<STR_LIT>' . format ( get . urlencode ( ) ) <EOL> if code == current_language : <EOL> status = '<STR_LIT>' <EOL> else : <EOL> status = '<STR_LIT>' <EOL> tabs . append ( ( url , get_language_title ( code ) , code , status ) ) <EOL> tabs . current_is_translated = current_language in available_languages <EOL> tabs . allow_deletion = len ( available_languages ) > <NUM_LIT:1> <EOL> return tabs <EOL> class TabsList ( list ) : <EOL> def __init__ ( self , seq = ( ) , css_class = None ) : <EOL> self . css_class = css_class <EOL> self . current_is_translated = False <EOL> self . allow_deletion = False <EOL> super ( TabsList , self ) . __init__ ( seq ) </s>
