From 0c56c9fa5358f24edfbf5add846886eff8ff9d95 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 14 Jun 2020 13:23:41 +0200 Subject: [PATCH] Multi-language support --- .../include/DockerContainers.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/dynamix.docker.manager/include/DockerContainers.php b/plugins/dynamix.docker.manager/include/DockerContainers.php index 376239356..681504187 100644 --- a/plugins/dynamix.docker.manager/include/DockerContainers.php +++ b/plugins/dynamix.docker.manager/include/DockerContainers.php @@ -48,13 +48,20 @@ $menu = []; $autostart = @file($autostart_file, FILE_IGNORE_NEW_LINES) ?: []; $names = array_map('var_split', $autostart); +function my_lang_time($text) { + [$number, $text] = explode(' ',$text,2); + return sprintf(_("%s $text"),$number); +} function my_lang_log($text) { global $language; if (isset($language['healthy'])) $text = str_replace('healthy',$language['healthy'],$text); if (isset($language['Exited'])) $text = str_replace('Exited',$language['Exited'],$text); - return _(_(_($text),2),0); + if (strpos($text,'ago')!==false) { + [$t1,$t2] = explode(') ',$text); + return $t1.'): '.my_lang_time($t2); + } + return _(_($text),2); } - foreach ($containers as $ct) { $name = $ct['Name']; $id = $ct['Id']; @@ -135,7 +142,7 @@ foreach ($containers as $ct) { echo ""; echo ""; echo "
"; - echo htmlspecialchars(str_replace('Up',_('Uptime'),my_lang_log($ct['Status'])))."
"._('Created')." ".htmlspecialchars(_($ct['Created'],0))."
"; + echo htmlspecialchars(str_replace('Up',_('Uptime').':',my_lang_log($ct['Status'])))."
"._('Created').": ".htmlspecialchars(my_lang_time($ct['Created']))."
"; } foreach ($images as $image) { if (count($image['usedBy'])) continue;