Multi-language support

This commit is contained in:
bergware
2020-04-30 16:33:27 +02:00
parent 5b2aae41e1
commit 2a15e234fd
4 changed files with 95 additions and 22 deletions
@@ -0,0 +1,38 @@
#!/usr/bin/php -q
<?PHP
/* 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,
* 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.
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$var = parse_ini_file('/var/local/emhttp/var.ini');
$current = parse_ini_file('/etc/unraid-version');
$unraid = parse_plugin_cfg('dynamix', true);
$notify = "$docroot/webGui/scripts/notify";
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['language_notify'];
language('checkall');
foreach (glob("/tmp/plugins/dynamix.*.xml", GLOB_NOSORT) as $file) {
$name = str_replace('dynamix.', '', basename($file));
$lang = language('Language', $file);
$new = language('Version', $file);
$old = language('Version', "/var/log/plugins/dynamix.$name");
// silently suppress bad download of XML file
if (strcmp($new, $old) > 0) {
exec("$notify -e ".escapeshellarg("Language - $lang [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $lang is available")." -i ".escapeshellarg("normal $output")." -x");
}
}
exit(0);
?>
+53 -22
View File
@@ -21,6 +21,10 @@ Tag="phone-square"
$events = explode('|', $notify['events']);
$disabled = $notify['system'] ? '' : 'disabled';
?>
<style>
select.a{min-width:220px}
span.a{display:inline-block;width:220px;font-style:italic}
</style>
<script>
function prepareNotify(form) {
form.entity.value = form.normal1.checked | form.warning1.checked | form.alert1.checked;
@@ -30,6 +34,7 @@ function prepareNotify(form) {
form.unraid.value = form.unraid1.checked*1 + form.unraid2.checked*2 + form.unraid3.checked*4;
form.plugin.value = form.plugin1.checked*1 + form.plugin2.checked*2 + form.plugin3.checked*4;
form.docker_notify.value = form.docker_notify1.checked*1 + form.docker_notify2.checked*2 + form.docker_notify3.checked*4;
form.language_notify.value = form.language_notify1.checked*1 + form.language_notify2.checked*2 + form.language_notify3.checked*4;
form.report.value = form.report1.checked*1 + form.report2.checked*2 + form.report3.checked*4;
form.normal1.disabled = true;
form.normal2.disabled = true;
@@ -49,6 +54,9 @@ function prepareNotify(form) {
form.docker_notify1.disabled = true;
form.docker_notify2.disabled = true;
form.docker_notify3.disabled = true;
form.language_notify1.disabled = true;
form.language_notify2.disabled = true;
form.language_notify3.disabled = true;
form.report1.disabled = true;
form.report2.disabled = true;
form.report3.disabled = true;
@@ -58,11 +66,12 @@ function prepareSystem(index) {
}
function prepareTitle() {
var title = '_(Available notifications)_:';
$('#unraidTitle,#pluginTitle,#dockerTitle,#reportTitle').html('&nbsp;');
if ($('.unraid').is(':visible')) { $('#unraidTitle').html(title); return; }
if ($('.plugin').is(':visible')) { $('#pluginTitle').html(title); return; }
if ($('.docker').is(':visible')) { $('#dockerTitle').html(title); return; }
if ($('.report').is(':visible')) { $('#reportTitle').html(title); return; }
$('#unraidTitle,#pluginTitle,#dockerTitle,#languageTitle,#reportTitle').html('&nbsp;');
if ($('.unraid').is(':visible')) {$('#unraidTitle').html(title); return;}
if ($('.plugin').is(':visible')) {$('#pluginTitle').html(title); return;}
if ($('.docker').is(':visible')) {$('#dockerTitle').html(title); return;}
if ($('.language').is(':visible')) {$('#languageTitle').html(title); return;}
if ($('.report').is(':visible')) {$('#reportTitle').html(title); return;}
}
function prepareUnraid(value) {
if (value=='') $('.unraid').hide(); else $('.unraid').show();
@@ -76,6 +85,10 @@ function prepareDocker(value) {
if (value=='') $('.docker').hide(); else $('.docker').show();
prepareTitle();
}
function prepareLanguage(value) {
if (value=='') $('.language').hide(); else $('.language').show();
prepareTitle();
}
function prepareReport(value) {
if (value=='') $('.report').hide(); else $('.report').show();
prepareTitle();
@@ -84,6 +97,7 @@ $(function(){
prepareUnraid(document.notify_settings.unraidos.value);
preparePlugin(document.notify_settings.version.value);
prepareDocker(document.notify_settings.docker_update.value);
prepareLanguage(document.notify_settings.language_update.value);
prepareReport(document.notify_settings.status.value);
});
</script>
@@ -99,9 +113,10 @@ $(function(){
<input type="hidden" name="unraid">
<input type="hidden" name="plugin">
<input type="hidden" name="docker_notify">
<input type="hidden" name="language_notify">
<input type="hidden" name="report">
_(Notifications display)_:
: <select name="display">
: <select class="a" name="display">
<?=mk_option($notify['display'], "0", _("Detailed"))?>
<?=mk_option($notify['display'], "1", _("Summarized"))?>
</select>
@@ -115,7 +130,7 @@ _(Notifications display)_:
:end
_(Date format)_:
: <select name="date">
: <select name="date" class="a">
<?=mk_option($notify['date'], "d-m-Y", _("DD-MM-YYYY"))?>
<?=mk_option($notify['date'], "m-d-Y", _("MM-DD-YYYY"))?>
<?=mk_option($notify['date'], "Y-m-d", _("YYYY-MM-DD"))?>
@@ -126,7 +141,7 @@ _(Date format)_:
:end
_(Time format)_:
: <select name="time">
: <select name="time" class="a">
<?=mk_option($notify['time'], "h:i A", _("12 hours"))?>
<?=mk_option($notify['time'], "H:i", _("24 hours"))?>
</select>
@@ -136,7 +151,7 @@ _(Time format)_:
:end
_(Display position)_:
: <select name="position">
: <select name="position" class="a">
<?=mk_option($notify['position'], "top-left", _("top-left"))?>
<?=mk_option($notify['position'], "top-right", _("top-right"))?>
<?=mk_option($notify['position'], "bottom-left", _("bottom-left"))?>
@@ -149,7 +164,7 @@ _(Display position)_:
:end
_(Store notifications to flash)_:
: <select name="path">
: <select name="path" class="a">
<?=mk_option($notify['path'], "/tmp/notifications", _("No"))?>
<?=mk_option($notify['path'], "/boot/config/plugins/dynamix/notifications", _("Yes"))?>
</select>
@@ -160,7 +175,7 @@ _(Store notifications to flash)_:
:end
_(System notifications)_:
: <select name="system" onchange="prepareSystem(this.selectedIndex)">
: <select name="system" class="a" onchange="prepareSystem(this.selectedIndex)">
<?=mk_option($notify['system'], "", _("Disabled"))?>
<?=mk_option($notify['system'], "*/1 * * * *", _("Enabled"))?>
</select>
@@ -171,7 +186,7 @@ _(System notifications)_:
:end
_(Unraid OS update notification)_:
: <select name="unraidos" onchange="prepareUnraid(this.value)">
: <select name="unraidos" class="a" onchange="prepareUnraid(this.value)">
<?=mk_option($notify['unraidos'], "", _("Never check"))?>
<?=mk_option($notify['unraidos'], "11 */6 * * *", _("Check four times a day"))?>
<?=mk_option($notify['unraidos'], "11 0,12 * * *", _("Check twice a day"))?>
@@ -186,7 +201,7 @@ _(Unraid OS update notification)_:
:end
_(Plugins update notification)_:
: <select name="version" onchange="preparePlugin(this.value)">
: <select name="version" class="a" onchange="preparePlugin(this.value)">
<?=mk_option($notify['version'], "", _("Never check"))?>
<?=mk_option($notify['version'], "10 */6 * * *", _("Check four times a day"))?>
<?=mk_option($notify['version'], "10 0,12 * * *", _("Check twice a day"))?>
@@ -201,7 +216,7 @@ _(Plugins update notification)_:
:end
_(Docker update notification)_:
: <select name="docker_update" onchange="prepareDocker(this.value)">
: <select name="docker_update" class="a" onchange="prepareDocker(this.value)">
<?=mk_option($notify['docker_update'], "", _("Never check"))?>
<?=mk_option($notify['docker_update'], "10 */6 * * *", _("Check four times a day"))?>
<?=mk_option($notify['docker_update'], "10 0,12 * * *", _("Check twice a day"))?>
@@ -215,8 +230,18 @@ _(Docker update notification)_:
> Use the checkboxes below to select how notifications need to be given; by browser, by email and/or by custom agent.
:end
_(Language update notification)_:
: <select name="language_update" class="a" onchange="prepareLanguage(this.value)">
<?=mk_option($notify['language_update'], "", _("Never check"))?>
<?=mk_option($notify['language_update'], "10 */6 * * *", _("Check four times a day"))?>
<?=mk_option($notify['language_update'], "10 0,12 * * *", _("Check twice a day"))?>
<?=mk_option($notify['language_update'], "10 0 * * *", _("Check once a day"))?>
<?=mk_option($notify['language_update'], "10 0 * * 1", _("Check once a week"))?>
<?=mk_option($notify['language_update'], "10 0 1 * *", _("Check once a month"))?>
</select>
_(Array status notification)_:
: <select name="status" onchange="prepareReport(this.value)">
: <select name="status" class="a" onchange="prepareReport(this.value)">
<?=mk_option($notify['status'], "", _("Never send"))?>
<?=mk_option($notify['status'], "20 * * * *", _("Send every hour"))?>
<?=mk_option($notify['status'], "20 */2 * * *", _("Send every two hours"))?>
@@ -233,25 +258,31 @@ _(Array status notification)_:
:end
<span id="unraidTitle" class="unraid" style="display:none">&nbsp;</span>
: <span class="unraid" style="display:none"><span style="display:inline-block;width:130px;font-style:italic">_(Unraid OS update)_</span>
: <span class="unraid" style="display:none"><span class="a">_(Unraid OS update)_</span>
<input type="checkbox" name="unraid1"<?=($notify['unraid'] & 1)==1 ? ' checked' : ''?>>_(Browser)_ &nbsp;
<input type="checkbox" name="unraid2"<?=($notify['unraid'] & 2)==2 ? ' checked' : ''?>>_(Email)_ &nbsp;
<input type="checkbox" name="unraid3"<?=($notify['unraid'] & 4)==4 ? ' checked' : ''?>>_(Agents)_ &nbsp;</span>
<span id="pluginTitle" class="plugin" style="display:none">&nbsp;</span>
: <span class="plugin" style="display:none"><span style="display:inline-block;width:130px;font-style:italic">_(Plugins update)_</span>
: <span class="plugin" style="display:none"><span class="a">_(Plugins update)_</span>
<input type="checkbox" name="plugin1"<?=($notify['plugin'] & 1)==1 ? ' checked' : ''?>>_(Browser)_ &nbsp;
<input type="checkbox" name="plugin2"<?=($notify['plugin'] & 2)==2 ? ' checked' : ''?>>_(Email)_ &nbsp;
<input type="checkbox" name="plugin3"<?=($notify['plugin'] & 4)==4 ? ' checked' : ''?>>_(Agents)_ &nbsp;</span>
<span id="dockerTitle" class="docker" style="display:none">&nbsp;</span>
: <span class="docker" style="display:none"><span style="display:inline-block;width:130px;font-style:italic">_(Docker update)_</span>
: <span class="docker" style="display:none"><span class="a">_(Docker update)_</span>
<input type="checkbox" name="docker_notify1"<?=($notify['docker_notify'] & 1)==1 ? ' checked' : ''?>>_(Browser)_ &nbsp;
<input type="checkbox" name="docker_notify2"<?=($notify['docker_notify'] & 2)==2 ? ' checked' : ''?>>_(Email)_ &nbsp;
<input type="checkbox" name="docker_notify3"<?=($notify['docker_notify'] & 4)==4 ? ' checked' : ''?>>_(Agents)_ &nbsp;</span>
<span id="languageTitle" class="language" style="display:none">&nbsp;</span>
: <span class="language" style="display:none"><span class="a">_(Language update)_</span>
<input type="checkbox" name="language_notify1"<?=($notify['language_notify'] & 1)==1 ? ' checked' : ''?>>_(Browser)_ &nbsp;
<input type="checkbox" name="language_notify2"<?=($notify['language_notify'] & 2)==2 ? ' checked' : ''?>>_(Email)_ &nbsp;
<input type="checkbox" name="language_notify3"<?=($notify['language_notify'] & 4)==4 ? ' checked' : ''?>>_(Agents)_ &nbsp;</span>
<span id="reportTitle" class="report" style="display:none">&nbsp;</span>
: <span class="report" style="display:none"><span style="display:inline-block;width:130px;font-style:italic">_(Array status)_</span>
: <span class="report" style="display:none"><span class="a">_(Array status)_</span>
<input type="checkbox" name="report1"<?=($notify['report'] & 1)==1 ? ' checked' : ''?>>_(Browser)_ &nbsp;
<input type="checkbox" name="report2"<?=($notify['report'] & 2)==2 ? ' checked' : ''?>>_(Email)_ &nbsp;
<input type="checkbox" name="report3"<?=($notify['report'] & 4)==4 ? ' checked' : ''?>>_(Agents)_ &nbsp;</span>
@@ -262,19 +293,19 @@ _(Array status notification)_:
:end
_(Notification entity)_:
: <span style="display:inline-block;width:130px;font-style:italic">_(Notices)_</span>
: <span class="a">_(Notices)_</span>
<input type="checkbox" class="checkbox" name="normal1"<?=($notify['normal'] & 1)==1 ? " checked $disabled" : $disabled?>>_(Browser)_ &nbsp;
<input type="checkbox" class="checkbox" name="normal2"<?=($notify['normal'] & 2)==2 ? " checked $disabled" : $disabled?>>_(Email)_ &nbsp;
<input type="checkbox" class="checkbox" name="normal3"<?=($notify['normal'] & 4)==4 ? " checked $disabled" : $disabled?>>_(Agents)_ &nbsp;
&nbsp;
: <span style="display:inline-block;width:130px;font-style:italic">_(Warnings)_</span>
: <span class="a">_(Warnings)_</span>
<input type="checkbox" class="checkbox" name="warning1"<?=($notify['warning'] & 1)==1 ? " checked $disabled" : $disabled?>>_(Browser)_ &nbsp;
<input type="checkbox" class="checkbox" name="warning2"<?=($notify['warning'] & 2)==2 ? " checked $disabled" : $disabled?>>_(Email)_ &nbsp;
<input type="checkbox" class="checkbox" name="warning3"<?=($notify['warning'] & 4)==4 ? " checked $disabled" : $disabled?>>_(Agents)_ &nbsp;
&nbsp;
: <span style="display:inline-block;width:130px;font-style:italic">_(Alerts)_</span>
: <span class="a">_(Alerts)_</span>
<input type="checkbox" class="checkbox" name="alert1"<?=($notify['alert'] & 1)==1 ? " checked $disabled" : $disabled?>>_(Browser)_ &nbsp;
<input type="checkbox" class="checkbox" name="alert2"<?=($notify['alert'] & 2)==2 ? " checked $disabled" : $disabled?>>_(Email)_ &nbsp;
<input type="checkbox" class="checkbox" name="alert3"<?=($notify['alert'] & 4)==4 ? " checked $disabled" : $disabled?>>_(Agents)_ &nbsp;
+2
View File
@@ -48,10 +48,12 @@ alert="1"
unraid="1"
plugin="1"
docker_notify="1"
language_notify="1"
report="1"
unraidos=""
version=""
docker_update=""
language_update=""
status=""
[ssmtp]
root=""
+2
View File
@@ -152,6 +152,8 @@ case 'cron-init':
parse_cron_cfg("dynamix", "monitor", $text);
$text = empty($notify['docker_update']) ? "" : "# Generated docker monitoring schedule:\n{$notify['docker_update']} $docroot/plugins/dynamix.docker.manager/scripts/dockerupdate.php check &> /dev/null\n\n";
parse_cron_cfg("dynamix", "docker-update", $text);
$text = empty($notify['language_update']) ? "" : "# Generated languages version check schedule:\n{$notify['language_update']} $docroot/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null\n\n";
parse_cron_cfg("dynamix", "language-check", $text);
break;
case 'add':