def get_languages_for_locale(locale):
 locale = locale.replace('-', '_')
 if (locale not in AVAILABLE_LANGUAGES):
  try:
   local_lang = babel.Locale(locale).languages
  except babel.UnknownLocaleError:
   return AVAILABLE_LANGUAGES['en']
  diff = [lc for lc in REFERENCE_LANGUAGE.keys() if (lc not in local_lang.keys())]
  for lc in diff:
   local_lang[lc] = REFERENCE_LANGUAGE[lc]
  for lang in REMOVE_LANGS:
   if (lang in local_lang):
    local_lang.pop(lang)
  local_lang = sorted([(key, value.capitalize()) for (key, value) in local_lang.items()], key=(lambda language: language[1]))
  AVAILABLE_LANGUAGES[locale] = local_lang
 return AVAILABLE_LANGUAGES[locale]

def get_languages_for_locale ( locale ) : locale = locale . replace ( '-' , '_' ) if ( locale not in AVAILABLE_LANGUAGES ) : try : local_lang = babel . Locale ( locale ) . languages except babel . UnknownLocaleError : return AVAILABLE_LANGUAGES [ 'en' ] diff = [ lc for lc in REFERENCE_LANGUAGE . keys ( ) if ( lc not in local_lang . keys ( ) ) ] for lc in diff : local_lang [ lc ] = REFERENCE_LANGUAGE [ lc ] for lang in REMOVE_LANGS : if ( lang in local_lang ) : local_lang . pop ( lang ) local_lang = sorted ( [ ( key , value . capitalize ( ) ) for ( key , value ) in local_lang . items ( ) ] , key = ( lambda language : language [ 1 ] ) ) AVAILABLE_LANGUAGES [ locale ] = local_lang return AVAILABLE_LANGUAGES [ locale ]
this method returns available languages localized in locale .