def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
 try:
  import _locale
  (code, encoding) = _locale._getdefaultlocale()
 except (ImportError, AttributeError):
  pass
 else:
  if ((sys.platform == 'win32') and code and (code[:2] == '0x')):
   code = windows_locale.get(int(code, 0))
  return (code, encoding)
 import os
 lookup = os.environ.get
 for variable in envvars:
  localename = lookup(variable, None)
  if localename:
   if (variable == 'LANGUAGE'):
    localename = localename.split(':')[0]
   break
 else:
  localename = 'C'
 return _parse_localename(localename)

def getdefaultlocale ( envvars = ( 'LC_ALL' , 'LC_CTYPE' , 'LANG' , 'LANGUAGE' ) ) : try : import _locale ( code , encoding ) = _locale . _getdefaultlocale ( ) except ( ImportError , AttributeError ) : pass else : if ( ( sys . platform == 'win32' ) and code and ( code [ : 2 ] == '0x' ) ) : code = windows_locale . get ( int ( code , 0 ) ) return ( code , encoding ) import os lookup = os . environ . get for variable in envvars : localename = lookup ( variable , None ) if localename : if ( variable == 'LANGUAGE' ) : localename = localename . split ( ':' ) [ 0 ] break else : localename = 'C' return _parse_localename ( localename )
tries to determine the default locale settings and returns them as tuple .