Files
webgui/emhttp/plugins/dynamix/LanguageButton.page
Tom Mortensen f9ec00b488 repo reorg
2023-06-02 12:49:33 -07:00

38 lines
1.0 KiB
Plaintext

Menu="Buttons:1"
Title="Switch Language"
Icon="icon-u-switch"
Code="e982"
---
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, 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>