mirror of
https://github.com/unraid/webgui.git
synced 2026-01-01 06:59:56 -06:00
- Wrapped multiple buttons and checkboxes in span elements to enhance layout consistency. - This change aligns with previous efforts to improve visual structure across the plugin.
130 lines
4.9 KiB
Plaintext
130 lines
4.9 KiB
Plaintext
Menu="WebGui"
|
|
Title="Language"
|
|
Icon="icon-language"
|
|
Tag="icon-language"
|
|
---
|
|
<?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.
|
|
*/
|
|
?>
|
|
<?
|
|
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
|
|
|
$installed = ['English'];
|
|
$plugins = '/var/log/plugins';
|
|
|
|
$keys = parse_ini_file('webGui/include/languages.key',false,INI_SCANNER_RAW);
|
|
$head = '<i class="fa fa-fw fa-trash" title="_(Remove the installed language)_" style="cursor:pointer" onclick="removeLanguage("';
|
|
$tail = '")"></i>';
|
|
|
|
foreach (glob("$plugins/lang-*.xml",GLOB_NOSORT) as $xml_file) $installed[] = language('LanguageLocal',$xml_file).$head.str_replace('lang-','',basename($xml_file,'.xml')).$tail;
|
|
?>
|
|
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.switchbutton.css')?>">
|
|
|
|
<script src="<?autov('/webGui/javascript/jquery.switchbutton.js')?>"></script>
|
|
<script>
|
|
function execute(cmd,title,language,name,filedata) {
|
|
var keys = {};
|
|
<?foreach ($keys as $key => $name) echo "keys['$key'] = '".strtok($keys[$key],' (')."'\n";?>
|
|
$.post("/webGui/include/FileUpload.php",{cmd:cmd,filename:language,name:encodeURIComponent(name),filedata:filedata},function(list){
|
|
if (list.indexOf('Error 500')==-1) {
|
|
var installed = [];
|
|
if (list.length) {
|
|
var name = list.split(',');
|
|
for (var i=0; i < name.length; i++) installed.push(keys[name[i]]+(name[i]!='en_US'? '<?=$head?>'+name[i]+'<?=$tail?>' : ''));
|
|
}
|
|
$('.installed').html(installed.join(', '));
|
|
swal({title:title,text:"_(See)_ <a href='/Settings/DisplaySettings'>_(Display Settings)_</a> _(to select your language)_",type:'success',html:true,confirmButtonText:"_(Ok)_"});
|
|
$('#uploadbutton').prop('disabled',true);
|
|
}
|
|
});
|
|
}
|
|
function removeLanguage(language) {
|
|
execute('rm', "_(Language support deleted)_", language, '', '');
|
|
}
|
|
function upload(form) {
|
|
var language = form.language;
|
|
if (!language.value) {
|
|
swal({title:"_(Missing Language)_",text:"_(Please select a language before proceeding)_!",type:'error',html:true,confirmButtonText:"_(Ok)_"});
|
|
return;
|
|
}
|
|
execute('add', "_(Language support added)_", language.value, language.options[language.selectedIndex].text, form.file.value);
|
|
}
|
|
function getZIPfile(event,form) {
|
|
var input = event.target;
|
|
var reader = new FileReader();
|
|
reader.onload = function(){
|
|
var name = input.files[0].name;
|
|
if (name.slice(-4)=='.zip') {
|
|
form.file.value = reader.result;
|
|
$('#uploadbutton').prop('disabled',false);
|
|
for (var n = 0; n < form.language.length; n++) if (form.language.options[n].text.indexOf(name.slice(0,-4))>0) {form.language.selectedIndex = n; break;}
|
|
} else {
|
|
swal({title:"_(Wrong File Extension)_",text:"_(Only ZIP files are allowed)_",type:'error',html:true,confirmButtonText:"_(Ok)_"});
|
|
}
|
|
};
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
function installXML(name) {
|
|
var file = name.trim();
|
|
if (file) openPlugin('language install '+file, "_(Install Language)_");
|
|
}
|
|
$(function() {
|
|
$('input.view').switchButton({labels_placement:'left', off_label:"_(User)_", on_label:"_(Developer)_"});
|
|
$('input.view').change(function(){$('.user,.developer').toggle('slow');});
|
|
});
|
|
</script>
|
|
|
|
|
|
: <span class="inline-block">
|
|
<input type="checkbox" class="view">
|
|
</span>
|
|
|
|
<div markdown="1" class="user">
|
|
<div class="notice">_(Use this to install official language packs)_</div>
|
|
_(Installed languages)_:
|
|
: <span class="installed"><?=implode(', ',$installed)?></span>
|
|
|
|
_(Enter URL of language pack XML file)_:
|
|
: <input type="text" id="xml_file" maxlength="1024" value="">
|
|
<span class="inline-block">
|
|
<input type="button" id="install" value="_(Install)_" onclick="installXML($('#xml_file').val())">
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div markdown="1" class="developer" style="display:none">
|
|
<div class="notice">_(Use this to develop language packs)_</div>
|
|
<form markdown="1">
|
|
<input type="hidden" name="file" value="">
|
|
|
|
_(Installed languages)_:
|
|
: <span class="installed"><?=implode(', ',$installed)?></span>
|
|
|
|
_(Select language)_:
|
|
: <select name="language" class="wide">
|
|
<?=mk_option(1, "", "---")?>
|
|
<?foreach ($keys as $key => $name) echo mk_option(1, $key, $name)?>
|
|
</select>
|
|
|
|
<div id="selectlang" markdown="1">
|
|
_(Select language file)_:
|
|
: <span><label for="files" class="button">_(Browse)_</label><input id="files" type="file" style="display:none" accept=".zip" onchange="getZIPfile(event,this.form)"></span>
|
|
|
|
</div>
|
|
|
|
: <span class="inline-block">
|
|
<input id="uploadbutton" type="button" value="_(Upload)_" onclick="upload(this.form)" disabled>
|
|
<input type="button" value="_(Done)_" class="lock" onclick="done()">
|
|
</span>
|
|
</form>
|
|
</div>
|