def default_locale(category=None, aliases=LOCALE_ALIASES):
 varnames = (category, 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')
 for name in filter(None, varnames):
  locale = os.getenv(name)
  if locale:
   if ((name == 'LANGUAGE') and (':' in locale)):
    locale = locale.split(':')[0]
   if (locale.split('.')[0] in ('C', 'POSIX')):
    locale = 'en_US_POSIX'
   elif (aliases and (locale in aliases)):
    locale = aliases[locale]
   try:
    return get_locale_identifier(parse_locale(locale))
   except ValueError:
    pass

def default_locale ( category = None , aliases = LOCALE_ALIASES ) : varnames = ( category , 'LANGUAGE' , 'LC_ALL' , 'LC_CTYPE' , 'LANG' ) for name in filter ( None , varnames ) : locale = os . getenv ( name ) if locale : if ( ( name == 'LANGUAGE' ) and ( ':' in locale ) ) : locale = locale . split ( ':' ) [ 0 ] if ( locale . split ( '.' ) [ 0 ] in ( 'C' , 'POSIX' ) ) : locale = 'en_US_POSIX' elif ( aliases and ( locale in aliases ) ) : locale = aliases [ locale ] try : return get_locale_identifier ( parse_locale ( locale ) ) except ValueError : pass
require the locale to be the default .