Commit 50d01bec authored by Franco Fichtner's avatar Franco Fichtner

src: do not reorder sprintf arguments by default

(Already had issues in the code that were obvious, some may still
linger in there.  Also uselessly confuses our dedicated translators.)
parent c6880a24
......@@ -332,7 +332,7 @@ function display_error_form($http_code, $desc)
global $config, $g;
$g['theme'] = get_current_theme();
if (isAjax()) {
printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc);
printf(gettext('Error: %s, Description: %s'), $http_code, $desc);
return;
}
......
......@@ -141,7 +141,7 @@ function convert_config()
}
if ($prev_version != $config['version']) {
write_config(sprintf(gettext('Upgraded config version level from %1$s to %2$s'), $prev_version, $config['version']));
write_config(sprintf(gettext('Upgraded config version level from %s to %s'), $prev_version, $config['version']));
}
}
......
......@@ -297,7 +297,7 @@ function filter_configure_sync($delete_states_if_needed = true)
$line_number = $line_error[1];
$line_split = file('/tmp/rules.debug');
if(is_array($line_split)) {
$line_error = sprintf(gettext('The line in question reads [%1$d]: %2$s'), $line_number, $line_split[$line_number-1]);
$line_error = sprintf(gettext('The line in question reads [%d]: %s'), $line_number, $line_split[$line_number-1]);
}
unset($line_split);
} else {
......@@ -315,8 +315,8 @@ function filter_configure_sync($delete_states_if_needed = true)
unset($rules_loading, $rules_error);
if ($line_error and $line_number) {
file_notice("filter_load", sprintf(gettext('There were error(s) loading the rules: %1$s - %2$s'), $saved_line_error, $line_error), "Filter Reload", "");
update_filter_reload_status(sprintf(gettext('There were error(s) loading the rules: %1$s - %2$s'), $saved_line_error, $line_error));
file_notice("filter_load", sprintf(gettext('There were error(s) loading the rules: %s - %s'), $saved_line_error, $line_error), "Filter Reload", "");
update_filter_reload_status(sprintf(gettext('There were error(s) loading the rules: %s - %s'), $saved_line_error, $line_error));
unlock($filterlck);
return;
}
......
......@@ -1534,7 +1534,7 @@ function interface_ppps_configure($interface)
$localips[$pid] = "0.0.0.0";
}
if(!is_ipaddr($gateways[$pid])){
log_error(sprintf(gettext('Could not get a PPTP/L2TP Remote IP address from %1$s for %2$s in interfaces_ppps_configure.'), $dhcp_gateway, $gway));
log_error(sprintf(gettext('Could not get a PPTP/L2TP Remote IP address from %s for %s in interfaces_ppps_configure.'), $dhcp_gateway, $gway));
return 0;
}
pfSense_ngctl_attach(".", $port);
......@@ -2208,7 +2208,7 @@ function interface_wireless_clone($realif, $wlcfg)
// example: wlan2
exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} bssid 2>&1", $out, $ret);
if($ret <> 0) {
log_error(sprintf(gettext('Failed to clone interface %1$s with error code %2$s, output %3$s'), $baseif, $ret, $out[0]));
log_error(sprintf(gettext('Failed to clone interface %s with error code %s, output %s'), $baseif, $ret, $out[0]));
return false;
}
$newif = trim($out[0]);
......@@ -2931,7 +2931,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
" link " . escapeshellarg($random_mac));
$wancfg['spoofmac'] = $random_mac;
write_config();
file_notice("MAC Address altered", sprintf(gettext('The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface %1$s has been automatically replaced with %2$s'), $realif, $random_mac), "Interfaces");
file_notice("MAC Address altered", sprintf(gettext('The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface %s has been automatically replaced with %s'), $realif, $random_mac), "Interfaces");
}
}
......
......@@ -293,8 +293,9 @@ function send_smtp_message($message, $subject = "(no subject)") {
log_error(sprintf(gettext("Message sent to %s OK"), $to));
return;
} else {
log_error(sprintf(gettext('Could not send the message to %1$s -- Error: %2$s'), $to, $smtp->error));
return(sprintf(gettext('Could not send the message to %1$s -- Error: %2$s'), $to, $smtp->error));
$msg = sprintf(gettext('Could not send the message to %s -- Error: %s'), $to, $smtp->error);
log_error($msg);
return ($msg);
}
}
......
......@@ -227,7 +227,7 @@ class smtp_class
&& !strcmp(@gethostbyname($this->exclude_address),$ip))
return(sprintf(gettext("domain \"%s\" resolved to an address excluded to be valid"), $domain));
if($this->debug)
$this->OutputDebug(sprintf(gettext('Connecting to host address "%1$s" port %2$s...'), $ip, $port));
$this->OutputDebug(sprintf(gettext('Connecting to host address "%s" port %s...'), $ip, $port));
if(($this->connection=($this->timeout ? @fsockopen(($this->ssl ? "ssl://" : "").$ip,$port,$errno,$error,$this->timeout) : @fsockopen(($this->ssl ? "ssl://" : "").$ip,$port))))
return("");
$error=($this->timeout ? strval($error) : "??");
......@@ -244,7 +244,7 @@ class smtp_class
case "-7":
return(gettext("-7 setvbuf() call failed"));
}
return(sprintf(gettext('could not connect to the host "%1$s": %2$s'), $domain, $error));
return(sprintf(gettext('could not connect to the host "%s": %s'), $domain, $error));
}
Function SASLAuthenticate($mechanisms, $credentials, &$authenticated, &$mechanism)
......
......@@ -71,7 +71,7 @@ function create_new_rrd($rrdcreatecmd) {
$_gb = exec("$rrdcreatecmd 2>&1", $rrdcreateoutput, $rrdcreatereturn);
if ($rrdcreatereturn <> 0) {
$rrdcreateoutput = implode(" ", $rrdcreateoutput);
log_error(sprintf(gettext('RRD create failed exited with %1$s, the error is: %2$s'), $rrdcreatereturn, $rrdcreateoutput));
log_error(sprintf(gettext('RRD create failed exited with %s, the error is: %s'), $rrdcreatereturn, $rrdcreateoutput));
}
unset($rrdcreateoutput);
return $rrdcreatereturn;
......
......@@ -422,7 +422,7 @@ function services_dhcpdv4_configure()
exec('cd /;LANG=C /usr/bin/tar -xzf /conf/dhcpleases.tgz 2>&1', $dhcprestore, $dhcpreturn);
$dhcprestore = implode(' ', $dhcprestore);
if($dhcpreturn <> 0) {
log_error(sprintf(gettext('DHCP leases restore failed exited with %1$s, the error is: %2$s%3$s'), $dhcpreturn, $dhcprestore, "\n"));
log_error(sprintf(gettext('DHCP leases restore failed exited with %s, the error is: %s'), $dhcpreturn, $dhcprestore));
}
}
}
......
......@@ -608,7 +608,7 @@ function compare_hostname_to_dnscache($hostname) {
}
if(trim($oldcontents) != trim($contents)) {
log_error(sprintf(gettext('DNSCACHE: Found old IP %1$s and new IP %2$s'), $oldcontents, $contents));
log_error(sprintf(gettext('DNSCACHE: Found old IP %s and new IP %s'), $oldcontents, $contents));
return ($oldcontents);
} else {
return false;
......
......@@ -37,7 +37,7 @@ function dump_rrd_to_xml($rrddatabase, $xmldumpfile)
exec("$rrdtool dump " . escapeshellarg($rrddatabase) . " {$xmldumpfile} 2>&1", $dumpout, $dumpret);
if ($dumpret <> 0) {
$dumpout = implode(" ", $dumpout);
log_error(sprintf(gettext('RRD dump failed exited with %1$s, the error is: %2$s'), $dumpret, $dumpout));
log_error(sprintf(gettext('RRD dump failed exited with %s, the error is: %s'), $dumpret, $dumpout));
}
return($dumpret);
......@@ -53,7 +53,7 @@ function migrate_rrd_format($rrdoldxml, $rrdnewxml) {
$numrranew = count($rrdnewxml['rra']);
$numdsold = count($rrdoldxml['ds']);
$numdsnew = count($rrdnewxml['ds']);
log_error(sprintf(gettext('Import RRD has %1$s DS values and %2$s RRA databases, new format RRD has %3$s DS values and %4$s RRA databases'), $numdsold, $numrraold, $numdsnew ,$numrranew));
log_error(sprintf(gettext('Import RRD has %s DS values and %s RRA databases, new format RRD has %s DS values and %s RRA databases'), $numdsold, $numrraold, $numdsnew ,$numrranew));
/* add data sources not found in the old array from the new array */
$i = 0;
......@@ -137,7 +137,7 @@ function migrate_rrd_format($rrdoldxml, $rrdnewxml) {
$numrranew = count($rrdoldxml['rra']);
$numdsnew = count($rrdoldxml['ds']);
log_error(sprintf(gettext('The new RRD now has %1$s DS values and %2$s RRA databases'), $numdsnew, $numrranew));
log_error(sprintf(gettext('The new RRD now has %s DS values and %s RRA databases'), $numdsnew, $numrranew));
return $rrdoldxml;
}
......
......@@ -80,7 +80,7 @@ function startElement($parser, $name, $attrs) {
} else if (isset($ptr)) {
/* multiple entries not allowed for this element, bail out */
die(sprintf(gettext('XML error: %1$s at line %2$d cannot occur more than once') . "\n",
die(sprintf(gettext('XML error: %s at line %d cannot occur more than once') . "\n",
$name,
xml_get_current_line_number($parser)));
}
......@@ -162,7 +162,7 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
log_error(sprintf(gettext('XML error: %1$s at line %2$d in %3$s') . "\n",
log_error(sprintf(gettext('XML error: %s at line %d in %s') . "\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser),
$cffile));
......
......@@ -42,7 +42,7 @@ list($vhid, $iface) = explode("@", $argument);
$friendly = convert_real_interface_to_friendly_interface_name($iface);
$carp_iface = "{$friendly}_vip{$vhid}";
$friendly_descr = convert_friendly_interface_to_friendly_descr($carp_iface);
$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "BACKUP" for vhid %s', $argument, $friendly_descr, $vhid);
$notificationmsg = sprintf('Carp cluster member "%s (%s)" has resumed the state "BACKUP" for vhid %s', $friendly_descr, $argument, $vhid);
notify_via_smtp($notificationmsg);
notify_via_growl($notificationmsg);
......
......@@ -42,7 +42,7 @@ list($vhid, $iface) = explode("@", $argument);
$friendly = convert_real_interface_to_friendly_interface_name($iface);
$carp_iface = "{$friendly}_vip${vhid}";
$friendly_descr = convert_friendly_interface_to_friendly_descr($carp_iface);
$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "MASTER" for vhid %s', $argument, $friendly_descr, $vhid);
$notificationmsg = sprintf('Carp cluster member "%s (%s)" has resumed the state "MASTER" for vhid %s', $friendly_descr, $argument, $vhid);
notify_via_smtp($notificationmsg);
notify_via_growl($notificationmsg);
......
......@@ -73,7 +73,7 @@ function restore_history_backup($number) {
$cnf = OPNsense\Core\Config::getInstance();
if($cnf->restoreBackup($filename)){
echo "\n";
echo sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $thisbackup['time']), $thisbackup['description']);
echo sprintf(gettext('Successfully reverted to timestamp %s with description "%s".'), date(gettext("n/j/y H:i:s"), $thisbackup['time']), $thisbackup['description']);
echo "\n" . gettext("You may need to reboot the firewall or restart services before the restored configuration is fully active.") . "\n\n";
} else {
echo gettext("Unable to revert to the selected configuration.") . "\n";
......
......@@ -44,7 +44,7 @@ if (isset($_POST['backupcount'])) {
foreach ($confvers as $filename => $revision) {
if (isset($revision['time']) && $revision['time'] == $_POST['newver']) {
if (config_restore($filename)== 0) {
$savemsg = sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['newver']), $revision['description']);
$savemsg = sprintf(gettext('Successfully reverted to timestamp %s with description "%s".'), date(gettext("n/j/y H:i:s"), $_POST['newver']), $revision['description']);
} else {
$savemsg = gettext("Unable to revert to the selected configuration.");
}
......@@ -56,7 +56,7 @@ if (isset($_POST['backupcount'])) {
if (isset($revision['time']) && $revision['time'] == $_POST['rmver']) {
if (file_exists($filename)) {
@unlink($filename);
$savemsg = sprintf(gettext('Deleted backup with timestamp %1$s and description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['rmver']),$revision['description']);
$savemsg = sprintf(gettext('Deleted backup with timestamp %s and description "%s".'), date(gettext("n/j/y H:i:s"), $_POST['rmver']),$revision['description']);
} else {
$savemsg = gettext("Unable to delete the selected configuration.");
}
......@@ -170,7 +170,7 @@ include("head.inc");
<input type="hidden" name="rmver" value="<?= htmlspecialchars($_GET['rmver']) ?>" />
<?php } ?>
<br /><strong><?= gettext('Target Configuration') ?>:</strong>
<?= sprintf(gettext('Timestamp %1$s'), date(gettext('n/j/y H:i:s'), $target_config)) ?>
<?= sprintf(gettext('Timestamp %s'), date(gettext('n/j/y H:i:s'), $target_config)) ?>
<br /><input type="submit" name="confirm" class="btn btn-primary" value="<?= gettext('Confirm') ?>" />
</div>
......
......@@ -391,7 +391,7 @@ function get_port_with_service($port, $proto) {
$service = getservbyport($port, $proto);
$portstr = "";
if ($service) {
$portstr = sprintf('<span title="' . gettext('Service %1$s/%2$s: %3$s') . '">' . htmlspecialchars($port) . '</span>', $port, $proto, $service);
$portstr = sprintf('<span title="Service %s/%s: %s">' . htmlspecialchars($port) . '</span>', $port, $proto, $service);
} else {
$portstr = htmlspecialchars($port);
}
......
......@@ -80,9 +80,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
foreach ($tonathosts as $tonathost) {
foreach ($automatic_rules as $natent) {
$natent['source']['network'] = $tonathost['subnet'];
$natent['descr'] .= sprintf(gettext(' - %1$s to %2$s'),
$tonathost['descr'],
convert_real_interface_to_friendly_descr($natent['interface']));
$natent['descr'] .= ' - ' . $tonathost['descr'] . ' -> ' . convert_real_interface_to_friendly_descr($natent['interface']);
$natent['created'] = make_config_revision_entry(null, gettext("Manual Outbound NAT Switch"));
/* Try to detect already auto created rules and avoid duplicate them */
......
......@@ -89,7 +89,7 @@ function startElement_attr($parser, $name, $attrs) {
} else if (isset($ptr)) {
/* multiple entries not allowed for this element, bail out */
die(sprintf(gettext('XML error: %1$s at line %2$d cannot occur more than once') . "\n",
die(sprintf(gettext('XML error: %s at line %d cannot occur more than once') . "\n",
$name,
xml_get_current_line_number($parser)));
} else if (isset($writeattrs)) {
......@@ -211,7 +211,7 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
log_error(sprintf(gettext('XML error: %1$s at line %2$d') . "\n",
log_error(sprintf(gettext('XML error: %s at line %d') . "\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
if (isset($parsed_attributes)) {
......
......@@ -43,7 +43,7 @@ require_once("unbound.inc");
function interface_assign_description($portinfo, $portname) {
if ($portinfo['isvlan']) {
$descr = sprintf(gettext('VLAN %1$s on %2$s'),$portinfo['tag'],$portinfo['if']);
$descr = sprintf(gettext('VLAN %s on %s'),$portinfo['tag'],$portinfo['if']);
if ($portinfo['descr'])
$descr .= " (" . $portinfo['descr'] . ")";
} elseif ($portinfo['iswlclone']) {
......@@ -268,9 +268,7 @@ if (isset($_POST['add_x']) && isset($_POST['if_add'])) {
/* Deliver error message for any port with more than one assignment */
foreach ($portifmap as $portname => $ifnames) {
if (count($ifnames) > 1) {
$errstr = sprintf(gettext('Port %1$s '.
' was assigned to %2$s' .
' interfaces:'), $portname, count($ifnames));
$errstr = sprintf(gettext('Port %s was assigned to %d interfaces:'), $portname, count($ifnames));
foreach ($portifmap[$portname] as $ifn)
$errstr .= " " . $ifn;
......
......@@ -115,7 +115,7 @@ if ($_POST) {
}
if (!$input_errors) {
if (!interface_wireless_clone($clone['cloneif'], $clone)) {
$input_errors[] = sprintf(gettext('Error creating interface with mode %1$s. The %2$s interface may not support creating more clones with the selected mode.'), $wlan_modes[$clone['mode']], $clone['if']);
$input_errors[] = sprintf(gettext('Error creating interface with mode %s. The %s interface may not support creating more clones with the selected mode.'), $wlan_modes[$clone['mode']], $clone['if']);
} else {
if (isset($id) && $a_clones[$id]) {
if ($clone['if'] != $a_clones[$id]['if'])
......
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
......@@ -50,10 +51,11 @@ if($_GET['wakeall'] <> "") {
continue;
$bcip = gen_subnet_max($ipaddr, get_interface_subnet($if));
/* Execute wol command and check return code. */
if (!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}"))
$savemsg .= sprintf(gettext('Sent magic packet to %1$s (%2$s)%3$s'),$mac, $description, ".<br />");
else
$savemsg .= sprintf(gettext('Please check the %1$ssystem log%2$s, the wol command for %3$s (%4$s) did not complete successfully%5$s'),'<a href="/diag_logs.php">','</a>',$description,$mac,".<br />");
if (!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}")) {
$savemsg = sprintf(gettext('Sent magic packet to %s (%s).'), $mac, $description);
} else {
$savemsg = sprintf(gettext('Please check the %ssystem log%s, the wol command for %s (%s) did not complete successfully.'), '<a href="/diag_logs.php">', '</a>', $description, $mac);
}
}
}
......@@ -86,10 +88,11 @@ if ($_POST || $_GET['mac']) {
else {
$bcip = gen_subnet_max($ipaddr, get_interface_subnet($if));
/* Execute wol command and check return code. */
if(!mwexec("/usr/local/bin/wol -i {$bcip} " . escapeshellarg($mac)))
$savemsg .= sprintf(gettext("Sent magic packet to %s."),$mac);
else
$savemsg .= sprintf(gettext('Please check the %1$ssystem log%2$s, the wol command for %3$s did not complete successfully%4$s'),'<a href="/diag_logs.php">', '</a>', $mac, ".<br />");
if(!mwexec("/usr/local/bin/wol -i {$bcip} " . escapeshellarg($mac))) {
$savemsg = sprintf(gettext('Sent magic packet to %s.'), $mac);
} else {
$savemsg = sprintf(gettext('Please check the %ssystem log%s, the wol command for %s did not complete successfully.'), '<a href="/diag_logs.php">', '</a>', $mac);
}
}
}
}
......
......@@ -230,7 +230,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
foreach ($a_phase1 as $ph1tmp) {
if ($p1index <> $t) {
if (isset($ph1tmp['remote-gateway']) && $ph1tmp['remote-gateway'] == $pconfig['remote-gateway'] && !isset($ph1tmp['disabled'])) {
$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $pconfig['remote-gateway'], $ph1tmp['descr']);
$input_errors[] = sprintf(gettext('The remote gateway "%s" is already used by phase1 "%s".'), $pconfig['remote-gateway'], $ph1tmp['descr']);
}
}
$t++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment