title: Change language in batch script - cmd
body: <p>In linux shell script I can change the language very easily, <a href="https://unix.stackexchange.com/questions/318782/set-language-bash-and-put-variables">using variables</a> to detect SO language and execute variables depending on the language:</p>
  
  <p>Example:</p>
  
  <pre><code># english
  echo "Hello world"
  blabla
  echo "Done"
  
  # spanish
  echo "Hola mundo"
  blabla
  echo "Terminado"
  
  # solution
  greeting=("Hello World" "Hola Mundo")
  goodbye=("Done" "Terminado")
  
  test "${LANG:0:2}" == "en"
  eng=$?
  
  echo ${greeting[${eng}]}
  blablabla
  echo ${goodbye[${eng}]}
  </code></pre>
  
  <p><strong>How can I do that in batch script - cmd?</strong></p>
  
  <p>Example bat script:</p>
  
  <pre><code># english
  echo Hello world
  blabla (cmd command)
  echo Bye
  
  # spanish
  echo Hola Mundo
  blabla (cmd command)
  echo Hasta la vista Baby
  </code></pre>
  
  <p>Update:</p>
  
  <p>I found <a href="https://superuser.com/questions/524416/how-to-get-windows-language-programmatically">this batch</a> maybe it can be useful (based on <a href="http://www.robvanderwoude.com/languagecodes.php" rel="nofollow noreferrer">Languaje Codes</a>)</p>
  
  <pre><code>set Key="HKEY_CURRENT_USER\Control Panel\International"
  for /F "tokens=3" %%a in ('reg query %Key% ^| find /i "LocaleName"') do set Language=%%a
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>set Language=en-US
  </code></pre>
  
  <p>but it is only necessary: <strong>en</strong></p>