def is_existing_language(language_code):
 try:
  get_babel_locale(language_code)
 except (UnknownLocaleError, ValueError):
  '\n        Catch errors with babel locale parsing\n\n        For example language `bew` raises `UnknownLocaleError`\n        and `ValueError` is being raised if language_code is\n        an empty string.\n        '
  return False
 return True

def is_existing_language ( language_code ) : try : get_babel_locale ( language_code ) except ( UnknownLocaleError , ValueError ) : return False return True
try to find out if language actually exists calling babel .