title: locale.getlocale() problems on OSX
body: <p>I need to get the system locale to do a number of things, ultimately I want to translate my app using gettext. I am going to distribute it on both Linux and OSX, but I ran into problems on OSX Snow Leopard:</p>
  
  <pre><code>$ python
  Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26) 
  [GCC 4.3.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import locale
  &gt;&gt;&gt; locale.setlocale(locale.LC_ALL, '')
  'sv_SE.UTF-8'
  &gt;&gt;&gt; locale.getlocale()
  ('sv_SE', 'UTF8')
  
  $ python
  Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
  [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import locale
  &gt;&gt;&gt; locale.setlocale(locale.LC_ALL, '')
  'C'
  &gt;&gt;&gt; locale.getlocale()
  (None, None)
  </code></pre>
  
  <p>Both systems are using Swedish languages. On Linux, the environment variable LANG is already set to "sv_SE.UTF-8". If I pass that variable to python on OSX (<code>LANG="sv_SE.UTF-8" python</code> instead), locale is detected nicely. But shouldn't <code>locale.getlocale()</code>be able to fetch whatever language the operating system has? I don't want to force users to set <code>LANG</code>, <code>LC_ALL</code> or any environment variable at all.</p>
  
  <p>Output of <code>locale</code> command:</p>
  
  <pre><code>$ locale
  LANG=
  LC_COLLATE="C"
  LC_CTYPE="C"
  LC_MESSAGES="C"
  LC_MONETARY="C"
  LC_NUMERIC="C"
  LC_TIME="C"
  LC_ALL=
  </code></pre>