@functools.lru_cache(maxsize=1000)
def get_supported_language_variant(lang_code, strict=False):
 if lang_code:
  possible_lang_codes = [lang_code]
  try:
   possible_lang_codes.extend(LANG_INFO[lang_code]['fallback'])
  except KeyError:
   pass
  generic_lang_code = lang_code.split('-')[0]
  possible_lang_codes.append(generic_lang_code)
  supported_lang_codes = get_languages()
  for code in possible_lang_codes:
   if ((code in supported_lang_codes) and check_for_language(code)):
    return code
  if (not strict):
   for supported_code in supported_lang_codes:
    if supported_code.startswith((generic_lang_code + '-')):
     return supported_code
 raise LookupError(lang_code)

@ functools . lru_cache ( maxsize = 1000 ) def get_supported_language_variant ( lang_code , strict = False ) : if lang_code : possible_lang_codes = [ lang_code ] try : possible_lang_codes . extend ( LANG_INFO [ lang_code ] [ 'fallback' ] ) except KeyError : pass generic_lang_code = lang_code . split ( '-' ) [ 0 ] possible_lang_codes . append ( generic_lang_code ) supported_lang_codes = get_languages ( ) for code in possible_lang_codes : if ( ( code in supported_lang_codes ) and check_for_language ( code ) ) : return code if ( not strict ) : for supported_code in supported_lang_codes : if supported_code . startswith ( ( generic_lang_code + '-' ) ) : return supported_code raise LookupError ( lang_code )
returns the language-code thats listed in supported languages .