title: What is the best way to detect a browser user's locale in 2012?
body: <p>I want to detect a user's locale (not their location). The problem is that none of the methods seem reliable.</p>
  
  <h1>Accept-Language Header</h1>
  
  <p>Pros</p>
  
  <ol>
  <li>You're meant to get a list of values which can reveal true locale if the browser has been altered to default to something else.</li>
  <li>Seems accurate in IE by default?</li>
  <li>Accurate in IE by default means accurate in FF on Windows by default? (i.e. you download the correct version from mozilla.org)</li>
  <li>Same as #3 for Opera on Windows?</li>
  </ol>
  
  <p>Cons</p>
  
  <ol>
  <li>Server side overhead and interference with caching (or an extra XHR).</li>
  <li>Defaults to "en-us" in Chrome on all systems for English unless you install your local dictionary and drag it to the top.</li>
  <li>Not sent by Safari?</li>
  <li>Incorrect by default in Safari and Chrome mean that <a href="http://mozilla.org">http://mozilla.org</a> and <a href="http://opera.com">http://opera.com</a> direct to the user to the wrong downloads and will also install "en-us" versions of themselves.</li>
  </ol>
  
  <p>Conclusion</p>
  
  <ul>
  <li>Completely unreliable on OSX since every browser will be wrong by default. However should be accurate in IE and FF on Windows.</li>
  </ul>
  
  <h1>window.navigator.language/userLanguage</h1>
  
  <p>Pros</p>
  
  <ol>
  <li>The best part of this is that it's nice lightweight client side solution.</li>
  <li>Seems accurate in IE by default?</li>
  <li>Seems accurate in FF on Windows by default?</li>
  </ol>
  
  <p>Cons</p>
  
  <ol>
  <li>Always "en-us" by default in Safari on all systems.</li>
  <li>Defaults to "en-us" in Chrome on all systems for English unless you install your local dictionary and drag it to the top.</li>
  <li>Always just "en" in Opera.</li>
  </ol>
  
  <p>Conclusion</p>
  
  <ul>
  <li>Even more unreliable than Accept-Language.</li>
  </ul>
  
  <h1>IP Geolocation</h1>
  
  <p>Pros</p>
  
  <ol>
  <li>Works independently of browser and OS language settings.</li>
  </ol>
  
  <p>Cons</p>
  
  <ol>
  <li>Works independently of browser and OS language settings.</li>
  <li>All the usual about performance, pricing, keeping it up to date, etc.</li>
  </ol>
  
  <p>Conclusion</p>
  
  <ul>
  <li>Whether this works really depends on <em>why</em> you're trying to detect a user's locale. This method gives you a user's locality which isn't the same as locale in an i18n sense.</li>
  </ul>
  
  <h1>HTML5 Geolocation</h1>
  
  <p>Pros</p>
  
  <ol>
  <li>Generally as accurate as IP geolocation without the server overhead.</li>
  </ol>
  
  <p>Cons</p>
  
  <ol>
  <li>Requires the user to allow you access to their location.</li>
  <li>Browser support (actually support looks pretty good).</li>
  </ol>
  
  <p>Conclusion</p>
  
  <ul>
  <li>Having to ask for permission is generally a deal breaker. Also same conclusion as IP geolocation.</li>
  </ul>
  
  <h1>Summary</h1>
  
  <p>It now seems like detecting a user's locale is harder than ever while detecting their physical location has become easier. The big offender is Safari which should at least reflect the OS settings by default on OSX but Chrome isn't setting any examples either. Even if people install their local dictionary to Chrome I really doubt they will also drag it to the top of the list.</p>
  
  <p>I can't blame Mozilla and Opera for getting dragged down by other browsers misreporting to their download pages. However it would mitigate the problem if they would switch their download pages to use geolocation instead of presumably looking at Accept-Language.</p>
  
  <p>But really, what options are left to detect a user's locale now that IE is no longer dominant? Is there anything left?</p>