Menu="Buttons:1"
Title="Switch Language"
Icon="icon-u-switch"
Code="e982"
---
<?PHP
/* Copyright 2005-2022, Lime Technology
 * Copyright 2012-2022, Bergware International.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 */
?>
<script>
<?if (count(glob('/var/log/plugins/lang-*.xml'))==0):?>
// hide switch button when no other language packs
$(function(){$('#nav-item.LanguageButton').hide();});
<?endif;?>

function LanguageButton() {
  var locale = '<?=$locale?>';
  if (locale) {
    switchLanguage('');
    $.cookie('locale',locale);
  } else {
    switchLanguage($.cookie('locale'));
    $.removeCookie('locale');
  }
}

function switchLanguage(lang) {
  $.post('/webGui/include/LanguageReset.php',{lang:lang},function(){location.reload();});
}
</script>