Localisation

This commit is contained in:
Sascha Leib
2025-10-25 21:14:35 +02:00
parent d49ab21345
commit 620d9253e5
10 changed files with 74 additions and 10 deletions

View File

@@ -309,6 +309,7 @@ class action_plugin_botmon extends DokuWiki_Action_Plugin {
}
private function insertCaptchaLoader() {
echo '<script>' . NL;
// add the deferred script loader::
@@ -318,6 +319,17 @@ class action_plugin_botmon extends DokuWiki_Action_Plugin {
echo DOKU_TAB . DOKU_TAB . "cj.src='".DOKU_BASE."lib/plugins/botmon/captcha.js';" . NL;
echo DOKU_TAB . DOKU_TAB . "document.getElementsByTagName('head')[0].appendChild(cj);" . NL;
echo DOKU_TAB . "});";
// add the locales for the captcha:
echo DOKU_TAB . '$BMLocales = {' . NL;
echo DOKU_TAB . DOKU_TAB . '"dlgTitle": ' . json_encode($this->getLang('bm_dlgTitle')) . ',' . NL;
echo DOKU_TAB . DOKU_TAB . '"dlgSubtitle": ' . json_encode($this->getLang('bm_dlgSubtitle')) . ',' . NL;
echo DOKU_TAB . DOKU_TAB . '"dlgConfirm": ' . json_encode($this->getLang('bm_dlgConfirm')) . ',' . NL;
echo DOKU_TAB . DOKU_TAB . '"dlgChecking": ' . json_encode($this->getLang('bm_dlgChecking')) . ',' . NL;
echo DOKU_TAB . DOKU_TAB . '"dlgLoading": ' . json_encode($this->getLang('bm_dlgLoading')) . ',' . NL;
echo DOKU_TAB . DOKU_TAB . '"dlgError": ' . json_encode($this->getLang('bm_dlgError')) . ',' . NL;
echo DOKU_TAB . '};' . NL;
echo '</script>' . NL;
}

View File

@@ -42,7 +42,7 @@ const BotMon = {
// get yesterday's date:
let d = new Date();
d.setDate(d.getDate() - 1);
if (BMSettings.showday == 'yesterday') d.setDate(d.getDate() - 1);
this._datestr = d.toISOString().slice(0, 10);
// init the sub-objects:
@@ -185,7 +185,7 @@ const BotMon = {
/* everything specific to the "Latest" tab is self-contained in the "live" object: */
BotMon.live = {
init: function() {
console.info('BotMon.live.init()');
//console.info('BotMon.live.init()');
// set the title:
const tDiff = '<abbr title="Coordinated Universal Time">UTC</abbr> ' + (BotMon._timeDiff != '' ? ` (offset: ${BotMon._timeDiff}` : '' ) + ')';
@@ -1056,13 +1056,13 @@ BotMon.live = {
const prefix = v.ip.split(':').slice(0, kIP6Segments).join(':');
rawIP = ipSeg.slice(0, kIP6Segments).join(':');
ipGroup = 'ip6-' + rawIP.replaceAll(':', '-');
ipName = prefix + '::' + '/' + (16 * kIP6Segments);
ipName = prefix + '::'; // + '/' + (16 * kIP6Segments);
} else {
ipSeg = ipAddr.split('.');
const prefix = v.ip.split('.').slice(0, kIP4Segments).join('.');
rawIP = ipSeg.slice(0, kIP4Segments).join('.') ;
ipGroup = 'ip4-' + rawIP.replaceAll('.', '-');
ipName = prefix + '.x.x.x'.substring(0, 1+(4-kIP4Segments)*2) + '/' + (8 * kIP4Segments);
ipName = prefix + '.x.x.x'.substring(0, 1+(4-kIP4Segments)*2); // + '/' + (8 * kIP4Segments);
}
}

View File

@@ -104,7 +104,13 @@ class admin_plugin_botmon extends AdminPlugin {
echo '<li>No files to process.</li>';
}
echo '</article></div><!-- End of BotMon Admin Tool -->';
echo '</article>' . NL;
echo '<script>
BMSettings = {
showDay: ' . json_encode($this->getConf('showDay')) . '
};
</script>';
echo '</div><!-- End of BotMon Admin Tool -->';
}

View File

@@ -13,6 +13,13 @@ const $BMCaptcha = {
},
install: function() {
// localisation helper function:
let _loc = function(id, alt) {
if ($BMLocales && $BMLocales[id]) return $BMLocales[id];
return alt;
}
// find the parent element:
let bm_parent = document.getElementsByTagName('body')[0];
@@ -22,11 +29,14 @@ const $BMCaptcha = {
dlg.setAttribute('open', 'open');
dlg.classList.add('checking');
dlg.id = 'botmon_captcha_box';
dlg.innerHTML = '<h2>Captcha box</h2><p>Making sure you are a human:</p>';
dlg.innerHTML = '<h2>' + _loc('dlgTitle', 'Title') + '</h2><p>' + _loc('dlgSubtitle', 'Subtitle') + '</p>';
// Checkbox:
const lbl = document.createElement('label');
lbl.innerHTML = '<span class="confirm">Click to confirm.</span><span class="busy"></span><span class="checking">Checking&nbsp;&hellip;</span><span class="loading">Loading&nbsp;&hellip;</span><span class="erricon">&#65533;</span><span class="error">An error occured.</span>';
lbl.innerHTML = '<span class="confirm">' + _loc('dlgConfirm', "Confirm.") + '</span>' +
'<span class="busy"></span><span class="checking">' + _loc('dlgChecking', "Checking") + '</span>' +
'<span class="loading">' + _loc('dlgLoading', "Loading") + '</span>' +
'<span class="erricon">&#65533;</span><span class="error">' + _loc('dlgError', "Error") + '</span>';
const cb = document.createElement('input');
cb.setAttribute('type', 'checkbox');
cb.setAttribute('disabled', 'disabled');

View File

@@ -5,6 +5,7 @@
* @author Sascha Leib <sascha@leib.be>
*/
$conf['showday'] = 'yesterday';
$conf['geoiplib'] = 'disabled';
$conf['useCaptcha'] = 'disabled';
$conf['captchaSeed'] = 'c53bc5f94929451987efa6c768d8856b';

View File

@@ -5,6 +5,9 @@
* @author Sascha Leib <sascha@leib.be>
*/
$meta['showday'] = array('multichoice',
'_choices' => array ('yesterday', 'today'));
$meta['geoiplib'] = array('multichoice',
'_choices' => array ('disabled', 'phpgeoip'));

View File

@@ -342,5 +342,5 @@
2a02:0598:0096:8a00:0000:0000:1200:0120 2a02:0598:0096:8a00:0000:0000:1200:013f 123
# localhosts
127.0.0.1 127.255.255.255 8
::1 ::1 128
#127.0.0.1 127.255.255.255 8
#::1 ::1 128

14
lang/de/lang.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
/**
* German language file for BotMon plugin
*
* @author Sascha Leib <ad@hominem.info>
*/
// Captcha dialog locale strings:
$lang['bm_dlgTitle'] = 'Benutzerüberprüfung';
$lang['bm_dlgSubtitle'] = 'Bitte bestätige, dass du kein Bot bist:';
$lang['bm_dlgConfirm'] = 'Klicke, um zu bestätigen.';
$lang['bm_dlgChecking'] = 'Wird überprüft&nbsp;&hellip;';
$lang['bm_dlgLoading'] = 'Seite wird geladen&nbsp;&hellip;';
$lang['bm_dlgError'] = 'Es ist ein Fehler aufgetreten.';

14
lang/en/lang.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
/**
* English language file for BotMon plugin
*
* @author Sascha Leib <ad@hominem.info>
*/
// Captcha dialog locale strings:
$lang['bm_dlgTitle'] = 'User Check';
$lang['bm_dlgSubtitle'] = 'Please confirm you are not a bot:';
$lang['bm_dlgConfirm'] = 'Click to confirm.';
$lang['bm_dlgChecking'] = 'Checking&nbsp;&hellip;';
$lang['bm_dlgLoading'] = 'Loading page&nbsp;&hellip;';
$lang['bm_dlgError'] = 'An error occured.';

View File

@@ -5,9 +5,13 @@
* @author Sascha Leib <sascha@leib.be>
*/
$lang['showday'] = 'Which data to show in the “Latest” tab:';
$lang['showday_o_yesterday'] = 'Last full day (yesterday)';
$lang['showday_o_today'] = 'Ongoing logs (today)';
$lang['geoiplib'] = 'Add GeoIP Information<br><small>(requires PHP module to be installed)</small>';
$lang['geoiplib_o_disabled'] = 'Disabled';
$lang['geoiplib_o_phpgeoip'] = 'Use GeoIP Module';
$lang['useCaptcha'] = 'Enable Captcha<br><small>(Experimental, read the manual first!)</small>';
$lang['captchaSeed'] = 'Captcha Seed<br><small>(Enter a 16 to 32 digits random number)</small>';
$lang['captchaSeed'] = 'Captcha Seed<br><small>(Best use a random number, e.g. <a href="https://www.browserling.com/tools/random-hex" target="_blank">here</a> )</small>';