From ff30e319d4239b4b6df55d2663f7c0f5efded5e1 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 21 Jan 2016 14:56:10 -0200 Subject: add call gettext function for translate --- src/usr/local/www/diag_backup.php | 12 +++++----- src/usr/local/www/diag_confbak.php | 4 ++-- src/usr/local/www/diag_dns.php | 2 +- src/usr/local/www/diag_halt.php | 2 +- src/usr/local/www/diag_nanobsd.php | 4 ++-- src/usr/local/www/diag_packet_capture.php | 26 ++++++++++----------- src/usr/local/www/diag_pftop.php | 38 ++++++++++++++++++------------- src/usr/local/www/diag_ping.php | 2 +- src/usr/local/www/diag_reboot.php | 8 +++---- src/usr/local/www/diag_resetstate.php | 21 ++++++++--------- src/usr/local/www/diag_smart.php | 4 ++-- src/usr/local/www/diag_traceroute.php | 2 +- 12 files changed, 64 insertions(+), 61 deletions(-) diff --git a/src/usr/local/www/diag_backup.php b/src/usr/local/www/diag_backup.php index cc48bc7..30da41b 100644 --- a/src/usr/local/www/diag_backup.php +++ b/src/usr/local/www/diag_backup.php @@ -108,7 +108,7 @@ function restore_rrddata() { $rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}"; $xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file); if (file_put_contents($xml_file, gzinflate(base64_decode($rrd['xmldata']))) === false) { - log_error("Cannot write $xml_file"); + log_error(sprintf(gettext("Cannot write %s"), $xml_file)); continue; } $output = array(); @@ -123,7 +123,7 @@ function restore_rrddata() { $rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}"; $rrd_fd = fopen($rrd_file, "w"); if (!$rrd_fd) { - log_error("Cannot write $rrd_file"); + log_error(sprintf(gettext("Cannot write %s"), $rrd_file)); continue; } $data = base64_decode($rrd['data']); @@ -132,18 +132,18 @@ function restore_rrddata() { if ($dcomp) { /* If the decompression worked, write the decompressed data */ if (fwrite($rrd_fd, $dcomp) === false) { - log_error("fwrite $rrd_file failed"); + log_error(sprintf(gettext("fwrite %s failed"), $rrd_file)); continue; } } else { /* If the decompression failed, it wasn't compressed, so write raw data */ if (fwrite($rrd_fd, $data) === false) { - log_error("fwrite $rrd_file failed"); + log_error(sprintf(gettext("fwrite %s failed"), $rrd_file)); continue; } } if (fclose($rrd_fd) === false) { - log_error("fclose $rrd_file failed"); + log_error(sprintf(gettext("fclose %s failed"), $rrd_file)); continue; } } @@ -370,7 +370,7 @@ if ($_POST) { $loaderconf = file_get_contents("/boot/loader.conf"); if (strpos($loaderconf, "console=\"comconsole")) { $config['system']['enableserial'] = true; - write_config("Restore serial console enabling in configuration."); + write_config(gettext("Restore serial console enabling in configuration.")); } unset($loaderconf); } diff --git a/src/usr/local/www/diag_confbak.php b/src/usr/local/www/diag_confbak.php index 2ada62c..554c6ca 100644 --- a/src/usr/local/www/diag_confbak.php +++ b/src/usr/local/www/diag_confbak.php @@ -69,9 +69,9 @@ if (isset($_POST['backupcount'])) { $changedescr = $config['system']['backupcount']; } else { unset($config['system']['backupcount']); - $changedescr = "(platform default)"; + $changedescr = gettext("(platform default)"); } - write_config("Changed backup revision count to {$changedescr}"); + write_config(sprintf(gettext("Changed backup revision count to %s"), $changedescr)); } elseif ($_GET) { if (!isset($_GET['newver']) && !isset($_GET['rmver']) && !isset($_GET['getcfg']) && !isset($_GET['diff'])) { header("Location: diag_confbak.php"); diff --git a/src/usr/local/www/diag_dns.php b/src/usr/local/www/diag_dns.php index 0acf06f..c9d5ba6 100755 --- a/src/usr/local/www/diag_dns.php +++ b/src/usr/local/www/diag_dns.php @@ -111,7 +111,7 @@ if (isset($_POST['create_alias']) && (is_hostname($host) || is_ipaddr($host))) { $newalias['name'] = $aliasname; $newalias['type'] = "network"; $newalias['address'] = $addresses; - $newalias['descr'] = "Created from Diagnostics-> DNS Lookup"; + $newalias['descr'] = gettext("Created from Diagnostics-> DNS Lookup"); if ($override) { $a_aliases[$id] = $newalias; } else { diff --git a/src/usr/local/www/diag_halt.php b/src/usr/local/www/diag_halt.php index 5d7fc5d..7e45554 100755 --- a/src/usr/local/www/diag_halt.php +++ b/src/usr/local/www/diag_halt.php @@ -87,7 +87,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { "); + print(sprintf(gettext("Not actually halting (DEBUG is set true)%s"), "
")); } else { print('
');
 		system_halt();
diff --git a/src/usr/local/www/diag_nanobsd.php b/src/usr/local/www/diag_nanobsd.php
index 2ecc2a1..26ab828 100644
--- a/src/usr/local/www/diag_nanobsd.php
+++ b/src/usr/local/www/diag_nanobsd.php
@@ -131,10 +131,10 @@ if ($_POST['setrw']) {
 			unset($config['system']['nanobsd_force_rw']);
 		}
 
-		write_config("Changed Permanent Read/Write Setting");
+		write_config(gettext("Changed Permanent Read/Write Setting"));
 		conf_mount_ro();
 	} else {
-		$savemsg = 'Saved r/w permanently';
+		$savemsg = gettext('Saved r/w permanently');
 		$class = 'alert-success';
 	}
 }
diff --git a/src/usr/local/www/diag_packet_capture.php b/src/usr/local/www/diag_packet_capture.php
index 5258f9b..64e2036 100644
--- a/src/usr/local/www/diag_packet_capture.php
+++ b/src/usr/local/www/diag_packet_capture.php
@@ -264,19 +264,19 @@ if ($_POST) {
 }
 
 $protocollist = array(
-	'' => 'Any',
+	'' => gettext('Any'),
 	'icmp' => 'ICMP',
-	'!icmp' => 'Exclude ICMP',
+	'!icmp' => gettext('Exclude ICMP'),
 	'icmp6' => 'ICMPv6',
-	'!icmp6' => 'Exclude ICMPv6',
+	'!icmp6' => gettext('Exclude ICMPv6'),
 	'tcp' => 'TCP',
-	'!tcp' => 'Exclude TCP',
+	'!tcp' => gettext('Exclude TCP'),
 	'udp' => 'UDP',
-	'!udp' => 'Exclude UDP',
+	'!udp' => gettext('Exclude UDP'),
 	'arp' => 'ARP',
-	'!arp' => 'Exclude ARP',
+	'!arp' => gettext('Exclude ARP'),
 	'carp' => 'CARP (VRRP)',
-	'!carp' => 'Exclude CARP (VRRP)',
+	'!carp' => gettext('Exclude CARP (VRRP)'),
 	'esp' => 'ESP'
 );
 
@@ -311,8 +311,8 @@ $section->addInput(new Form_Select(
 	'Address Family',
 	$fam,
 	array('' => 'Any',
-		  'ip' => 'IPv4 Only',
-		  'ip6' => 'IPv6 Only'
+		  'ip' => gettext('IPv4 Only'),
+		  'ip6' => gettext('IPv6 Only')
 	)
 ))->setHelp('Select the type of traffic to be captured');
 
@@ -361,10 +361,10 @@ $section->addInput(new Form_Select(
 	'detail',
 	'Level of detail',
 	$detail,
-	array('normal' => 'Normal',
-		  'medium' => 'Medium',
-		  'high' => 'High',
-		  'full' => 'Full',
+	array('normal' => gettext('Normal'),
+		  'medium' => gettext('Medium'),
+		  'high' => gettext('High'),
+		  'full' => gettext('Full'),
 	)
 ))->setHelp('This is the level of detail that will be displayed after hitting "Stop" when the packets have been captured.' . '
' . 'This option does not affect the level of detail when downloading the packet capture. '); diff --git a/src/usr/local/www/diag_pftop.php b/src/usr/local/www/diag_pftop.php index cece7aa..b7604d6 100644 --- a/src/usr/local/www/diag_pftop.php +++ b/src/usr/local/www/diag_pftop.php @@ -125,15 +125,21 @@ $form->addGlobal(new Form_Input( $section = new Form_Section('pfTop Configuration'); $validViews = array( - 'default', 'label', 'long', - 'queue', 'rules', 'size', - 'speed', 'state', 'time', + 'default' => gettext('default'), + 'label' => gettext('label'), + 'long' => gettext('long'), + 'queue' => gettext('queue'), + 'rules' => gettext('rules'), + 'size' => gettext('size'), + 'speed' => gettext('speed'), + 'state' => gettext('state'), + 'time' => gettext('time'), ); $section->addInput(new Form_Select( 'viewtype', 'View', $viewtype, - array_combine($validViews, $validViews) + $validViews )); $section->addInput(new Form_Select( @@ -141,18 +147,18 @@ $section->addInput(new Form_Select( 'Sort by', $sorttype, array( - 'none' => 'None', - 'age' => 'Age', - 'bytes' => 'Bytes', - 'dest' => 'Destination Address', - 'dport' => 'Destination Port', - 'exp' => 'Expiry', - 'peak' => 'Peak', - 'pkt' => 'Packet', - 'rate' => 'Rate', - 'size' => 'Size', - 'sport' => 'Source Port', - 'src' => 'Source Address', + 'none' => gettext('None'), + 'age' => gettext('Age'), + 'bytes' => gettext('Bytes'), + 'dest' => gettext('Destination Address'), + 'dport' => gettext('Destination Port'), + 'exp' => gettext('Expiry'), + 'peak' => gettext('Peak'), + 'pkt' => gettext('Packet'), + 'rate' => gettext('Rate'), + 'size' => gettext('Size'), + 'sport' => gettext('Source Port'), + 'src' => gettext('Source Address'), ) )); diff --git a/src/usr/local/www/diag_ping.php b/src/usr/local/www/diag_ping.php index b99f595..c35ee7e 100644 --- a/src/usr/local/www/diag_ping.php +++ b/src/usr/local/www/diag_ping.php @@ -77,7 +77,7 @@ $count = DEFAULT_COUNT; function create_sourceaddresslist() { $sourceips = get_possible_traffic_source_addresses(true); - $list = array("" => 'Default'); + $list = array("" => gettext('Default')); foreach ($sourceips as $sipvalue => $sipname) { $list[$sipvalue] = $sipname; diff --git a/src/usr/local/www/diag_reboot.php b/src/usr/local/www/diag_reboot.php index d1f3393..b347d30 100755 --- a/src/usr/local/www/diag_reboot.php +++ b/src/usr/local/www/diag_reboot.php @@ -79,7 +79,7 @@ include("head.inc"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (DEBUG) { - print_info_box("Not actually rebooting (DEBUG is set true)", 'success'); + print_info_box(gettext("Not actually rebooting (DEBUG is set true)"), 'success'); } else { print('
');
 		system_reboot();
@@ -94,7 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
 //Rebooting
Page will automatically reload in '; + var timeoutmsg = '


'; var time = 0; function checkonline() { @@ -110,11 +110,11 @@ events.push(function() { function startCountdown() { setInterval(function() { if (time > 0) { - $('#countdown').html(timeoutmsg + time + ' seconds.

'); + $('#countdown').html(timeoutmsg + time + ' .'); time--; } else { time = ""; - timeoutmsg = '

Not yet ready
Retrying in another '; + timeoutmsg = '


'; checkonline(); } }, 1000); diff --git a/src/usr/local/www/diag_resetstate.php b/src/usr/local/www/diag_resetstate.php index e492550..45589eb 100644 --- a/src/usr/local/www/diag_resetstate.php +++ b/src/usr/local/www/diag_resetstate.php @@ -97,20 +97,17 @@ if ($savemsg) { print_info_box($savemsg, 'alert-success'); } -$statetablehelp = 'Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' . +$statetablehelp = sprintf(gettext('Resetting the state tables will remove all entries from the corresponding tables. This means that all open connections ' . 'will be broken and will have to be re-established. This may be necessary after making substantial changes to the ' . - 'firewall and/or NAT rules, especially if there are IP protocol mappings (e.g. for PPTP or IPv6) with open connections.' . - '

' . - 'The firewall will normally leave the state tables intact when changing rules.' . - '

' . - 'NOTE: If you reset the firewall state table, the browser session may appear to be hung after clicking "Reset". ' . - 'Simply refresh the page to continue.'; - -$sourcetablehelp = 'Resetting the source tracking table will remove all source/destination associations. ' . + 'firewall and/or NAT rules, especially if there are IP protocol mappings (e.g. for PPTP or IPv6) with open connections.%s' . + 'The firewall will normally leave the state tables intact when changing rules.%s' . + '%sNOTE:%s If you reset the firewall state table, the browser session may appear to be hung after clicking "Reset". ' . + 'Simply refresh the page to continue.'), "

", "

", "", ""); + +$sourcetablehelp = sprintf(gettext('Resetting the source tracking table will remove all source/destination associations. ' . 'This means that the \"sticky\" source/destination association ' . - 'will be cleared for all clients.' . - '

' . - 'This does not clear active connection states, only source tracking.'; + 'will be cleared for all clients.%s' . + 'This does not clear active connection states, only source tracking.'), "

"); $tab_array = array(); $tab_array[] = array(gettext("States"), false, "diag_dump_states.php"); diff --git a/src/usr/local/www/diag_smart.php b/src/usr/local/www/diag_smart.php index ad878dc..7ea6efa 100644 --- a/src/usr/local/www/diag_smart.php +++ b/src/usr/local/www/diag_smart.php @@ -111,7 +111,7 @@ $action = (isset($_POST['action']) ? $_POST['action'] : $_GET['action']); $targetdev = basename($_POST['device']); if (!file_exists('/dev/' . $targetdev)) { - echo "Device does not exist, bailing."; + echo gettext("Device does not exist, bailing."); return; } @@ -126,7 +126,7 @@ switch ($action) { { $test = $_POST['testType']; if (!in_array($test, $valid_test_types)) { - echo "Invalid test type, bailing."; + echo gettext("Invalid test type, bailing."); return; } diff --git a/src/usr/local/www/diag_traceroute.php b/src/usr/local/www/diag_traceroute.php index 2ccd98e..f0b22b0 100644 --- a/src/usr/local/www/diag_traceroute.php +++ b/src/usr/local/www/diag_traceroute.php @@ -81,7 +81,7 @@ $ipproto = 'ipv4'; $sourceip = 'any'; function create_sourceaddresslist() { - $list = array('any' => 'Any'); + $list = array('any' => gettext('Any')); $sourceips = get_possible_traffic_source_addresses(true); -- cgit v1.1