title: Change language code in URL using Javascript
body: <p>I am developing a website that works in two languages. I need to change URL to include the selected language.</p>
  <p>What I exactly need is:</p>
  <ol>
  <li>Pick the current URL</li>
  <li>Check if the URL contains any language code</li>
  <li>Append the code if not exist or change the code to the selected one if exists</li>
  </ol>
  <p>For example, there is an URL for English (default):</p>
  <pre><code>http://localhost:11767/Home/resultMain?model=1&amp;&amp;type=1
  </code></pre>
  <p>When a user selects Spanish (es) it should be:</p>
  <pre><code>http://localhost:11767/es/Home/resultMain?model=1&amp;&amp;type=1
  </code></pre>