title: Get visitors language & country code with javascript (client-side)
body: <p><strong>Question:</strong> Is there a javascript (client-side) code to get visitors country/language code, that is accurate and is cross-"modern"-browser ? I am looking for results like <code>'en-US'</code>, <code>'sv-SE'</code>, <code>'nl-NL'</code>, etc.</p>
  
  <p>Related questions to this have been asked before (some SO links: <a href="https://stackoverflow.com/questions/673905/best-way-to-determine-users-locale-within-browser">1</a>,<a href="https://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference">2</a>,<a href="https://stackoverflow.com/questions/15327726/how-to-change-date-format-according-to-the-country">3</a>,<a href="https://stackoverflow.com/questions/17588228/how-to-detect-visitor-country">4</a>, among others) but I didn't find answer and some of the answers  are some yearls old and in some cases referring to even more old articles, which makes me think there are new solutions for this.</p>
  
  <p>I tried :</p>
  
  <pre><code>var language = window.navigator.userLanguage || window.navigator.language;
  console.log(language);
  </code></pre>
  
  <p>and got <code>"sv"</code> in Chrome and <code>"en-GB"</code> in Firefox, in the same machine, same place.</p>