def find_languages(string, context=None):
 allowed_languages = context.get('allowed_languages')
 common_words = (COMMON_WORDS_STRICT if allowed_languages else COMMON_WORDS)
 matches = []
 for word_match in iter_words(string):
  word = word_match.value
  (start, end) = word_match.span
  lang_word = word.lower()
  key = 'language'
  for prefix in subtitle_prefixes:
   if lang_word.startswith(prefix):
    lang_word = lang_word[len(prefix):]
    key = 'subtitle_language'
  for suffix in subtitle_suffixes:
   if lang_word.endswith(suffix):
    lang_word = lang_word[:(len(lang_word) - len(suffix))]
    key = 'subtitle_language'
  for prefix in lang_prefixes:
   if lang_word.startswith(prefix):
    lang_word = lang_word[len(prefix):]
  if ((lang_word not in common_words) and (word.lower() not in common_words)):
   try:
    lang = babelfish.Language.fromguessit(lang_word)
    match = (start, end, {'name': key, 'value': lang})
    if allowed_languages:
     if ((lang.name.lower() in allowed_languages) or (lang.alpha2.lower() in allowed_languages) or (lang.alpha3.lower() in allowed_languages)):
      matches.append(match)
    elif ((lang == 'mul') or hasattr(lang, 'alpha2')):
     matches.append(match)
   except babelfish.Error:
    pass
 return matches

def find_languages ( string , context = None ) : allowed_languages = context . get ( 'allowed_languages' ) common_words = ( COMMON_WORDS_STRICT if allowed_languages else COMMON_WORDS ) matches = [ ] for word_match in iter_words ( string ) : word = word_match . value ( start , end ) = word_match . span lang_word = word . lower ( ) key = 'language' for prefix in subtitle_prefixes : if lang_word . startswith ( prefix ) : lang_word = lang_word [ len ( prefix ) : ] key = 'subtitle_language' for suffix in subtitle_suffixes : if lang_word . endswith ( suffix ) : lang_word = lang_word [ : ( len ( lang_word ) - len ( suffix ) ) ] key = 'subtitle_language' for prefix in lang_prefixes : if lang_word . startswith ( prefix ) : lang_word = lang_word [ len ( prefix ) : ] if ( ( lang_word not in common_words ) and ( word . lower ( ) not in common_words ) ) : try : lang = babelfish . Language . fromguessit ( lang_word ) match = ( start , end , { 'name' : key , 'value' : lang } ) if allowed_languages : if ( ( lang . name . lower ( ) in allowed_languages ) or ( lang . alpha2 . lower ( ) in allowed_languages ) or ( lang . alpha3 . lower ( ) in allowed_languages ) ) : matches . append ( match ) elif ( ( lang == 'mul' ) or hasattr ( lang , 'alpha2' ) ) : matches . append ( match ) except babelfish . Error : pass return matches
generate supported languages list from the .