def is_valid_locale(locale_n):
 try:
  locale.setlocale(locale.LC_ALL, locale_n)
  return True
 except locale.Error:
  return False

def is_valid_locale ( locale_n ) : try : locale . setlocale ( locale . LC_ALL , locale_n ) return True except locale . Error : return False
check if locale is valid .