Multi-language support

This commit is contained in:
bergware
2020-03-13 07:59:24 +01:00
parent c4398c2724
commit d9ab82e15f
6 changed files with 39 additions and 20 deletions
@@ -12,12 +12,16 @@
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
$_SERVER['REQUEST_URI'] = 'docker';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/Helpers.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Container Size</title>
<title><?=_('Container Size')?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="robots" content="noindex, nofollow">
@@ -55,6 +59,6 @@ $(function(){
<body style='margin:20px'>
<div class="spinner"></div>
<pre id="data"></pre>
<div class="button"><input type="button" value="Done" onclick="top.Shadowbox.close()"></div>
<div class="button"><input type="button" value="<?=_('Done')?>" onclick="top.Shadowbox.close()"></div>
</body>
</html>
@@ -1,7 +1,7 @@
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2014-2018, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2018, Bergware International.
/* Copyright 2005-2020, Lime Technology
* Copyright 2014-2020, Guilherme Jardim, Eric Schultz, Jon Panozzo.
* Copyright 2012-2020, 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,
@@ -13,6 +13,10 @@
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
$_SERVER['REQUEST_URI'] = 'docker';
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$DockerClient = new DockerClient();
@@ -21,7 +25,7 @@ $action = $_REQUEST['action'] ?? '';
$container = $_REQUEST['container'] ?? '';
$name = $_REQUEST['name'] ?? '';
$image = $_REQUEST['image'] ?? '';
$arrResponse = ['error' => 'Missing parameters'];
$arrResponse = ['error' => _('Missing parameters')];
switch ($action) {
case 'start':
@@ -66,7 +70,7 @@ switch ($action) {
if (!$since) {
readfile("$docroot/plugins/dynamix.docker.manager/log.htm");
echo "<script>document.title = '$title';</script>";
echo "<script>addLog('".addslashes("<p style='text-align:center'><span class='error label'>Error</span><span class='warn label'>Warning</span><span class='system label'>System</span><span class='array label'>Array</span><span class='login label'>Login</span></p>")."');</script>";
echo "<script>addLog('".addslashes("<p style='text-align:center'><span class='error label'>"._('Error')."</span><span class='warn label'>"._('Warning')."</span><span class='system label'>"._('System')."</span><span class='array label'>"._('Array')."</span><span class='login label'>"._('Login')."</span></p>")."');</script>";
$tail = 350;
} else {
$tail = null;
@@ -99,7 +103,7 @@ switch ($action) {
exec("exec ttyd -o -d0 -i '/var/tmp/$name.sock' docker exec -it '$name' $shell &>/dev/null &");
break;
default:
$arrResponse = ['error' => "Unknown action '$action'"];
$arrResponse = ['error' => _('Unknown action')." '$action'"];
break;
}
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2012-2018, Bergware International.
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, 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,
@@ -11,6 +11,11 @@
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
// add translations
$_SERVER['REQUEST_URI'] = 'docker';
require_once "$docroot/webGui/include/Translations.php";
$unit = ['B','kB','MB','GB','TB','PB','EB','ZB','YB'];
$list = [];
@@ -34,12 +39,12 @@ function align($text, $w=13) {
}
exec("docker ps -sa --format='{{.Names}}|{{.Size}}'",$container);
echo align('Name',-30).align('Container').align('Writable').align('Log')."\n";
echo align(_('Name'),-30).align(_('Container')).align(_('Writable')).align(_('Log'))."\n";
echo str_repeat('-',69)."\n";
foreach ($container as $ct) {
list($name,$size) = explode('|',$ct);
list($writable,$dummy,$total) = explode(' ',str_replace(['(',')'],'',$size));
list($value,$base) = explode(' ',gap($total));
[$name,$size] = explode('|',$ct);
[$writable,$dummy,$total] = explode(' ',str_replace(['(',')'],'',$size));
[$value,$base] = explode(' ',gap($total));
$list[] = ['name' => $name, 'total' => $value*pow(1000,array_search($base,$unit)), 'writable' => $writable, 'log' => (exec("docker inspect --format='{{.LogPath}}' $name|xargs du -b 2>/dev/null |cut -f1")) ?: "0"];
}
array_multisort(array_column($list,'total'),SORT_DESC,$list); // sort on container size