Multi-language support

This commit is contained in:
bergware
2020-04-29 23:56:29 +02:00
parent d016ac9385
commit ecec49e39a
2 changed files with 12 additions and 3 deletions
@@ -101,7 +101,12 @@ function language($method, $xml_file, &$error) {
exec("mkdir -p $path");
@unlink("$docroot/webGui/javascript/translate.$name.js");
foreach (glob("$path/*.dot",GLOB_NOSORT) as $dot) unlink($dot);
exec("unzip -qqLjo -d $path $local");
exec("unzip -qqLjo -d $path $local", $dummy, $err);
if ($err > 1) {
exec("rm -rf $path");
$error = "unzip failed. Error code $err";
return false;
}
return true;
case 'remove':
$url = $xml->LanguageURL;
+6 -2
View File
@@ -50,11 +50,15 @@ case 'delete':
case 'add':
$path = "$docroot/languages/$file";
exec("mkdir -p ".escapeshellarg($path));
$result = file_put_contents("/$boot/$file.lang.zip",base64_decode(preg_replace('/^data:.*;base64,/','',$_POST['filedata'])));
$result = file_put_contents("$boot/$file.lang.zip",base64_decode(preg_replace('/^data:.*;base64,/','',$_POST['filedata'])));
if ($result) {
foreach (glob("$path/*.dot",GLOB_NOSORT) as $dot) unlink($dot);
@unlink("$docroot/webGui/javascript/translate.$file.js");
exec("unzip -qqjLo -d ".escapeshellarg($path)." ".escapeshellarg("$boot/$file.lang.zip"));
exec("unzip -qqjLo -d ".escapeshellarg($path)." ".escapeshellarg("$boot/$file.lang.zip"), $dummy, $err);
if ($err > 1) {
unlink("$boot/$file.lang.zip");
exec("rm -rf ".escapeshellarg($path));
}
}
$installed = [];
foreach (glob("$docroot/languages/*",GLOB_ONLYDIR) as $dir) $installed[] = basename($dir);