def guess_language(lang_list=None):
 lang_codes = frappe.request.accept_languages.values()
 if (not lang_codes):
  return frappe.local.lang
 guess = None
 if (not lang_list):
  lang_list = (get_all_languages() or [])
 for l in lang_codes:
  code = l.strip()
  if (not isinstance(code, unicode)):
   code = unicode(code, u'utf-8')
  if ((code in lang_list) or (code == u'en')):
   guess = code
   break
  if (u'-' in code):
   code = code.split(u'-')[0]
   if (code in lang_list):
    guess = code
    break
 return (guess or frappe.local.lang)

def guess_language ( lang_list = None ) : lang_codes = frappe . request . accept_languages . values ( ) if ( not lang_codes ) : return frappe . local . lang guess = None if ( not lang_list ) : lang_list = ( get_all_languages ( ) or [ ] ) for l in lang_codes : code = l . strip ( ) if ( not isinstance ( code , unicode ) ) : code = unicode ( code , u'utf-8' ) if ( ( code in lang_list ) or ( code == u'en' ) ) : guess = code break if ( u'-' in code ) : code = code . split ( u'-' ) [ 0 ] if ( code in lang_list ) : guess = code break return ( guess or frappe . local . lang )
passed a string .