def get_language_code(language_code, site_id=None):
 if (not language_code):
  return None
 languages = get_language_list(site_id)
 if (language_code in languages):
  return language_code
 for lang in languages:
  if (language_code.split('-')[0] == lang):
   return lang
  if (lang.split('-')[0] == language_code):
   return lang
 return language_code

def get_language_code ( language_code , site_id = None ) : if ( not language_code ) : return None languages = get_language_list ( site_id ) if ( language_code in languages ) : return language_code for lang in languages : if ( language_code . split ( '-' ) [ 0 ] == lang ) : return lang if ( lang . split ( '-' ) [ 0 ] == language_code ) : return lang return language_code
returns language code while making sure its in languages .