From 51a14c58a0f6728032a41626480f6f547e16f511 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 19 Feb 2016 18:07:26 +0545 Subject: Internationalize etc inc uvx --- src/etc/inc/upgrade_config.inc | 10 +++----- src/etc/inc/util.inc | 6 ++--- src/etc/inc/voucher.inc | 58 ++++++++++++++++++++++-------------------- src/etc/inc/vpn.inc | 44 ++++++++++++++++---------------- src/etc/inc/xmlrpc.inc | 2 +- 5 files changed, 61 insertions(+), 59 deletions(-) (limited to 'src/etc') diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index 5ec1870..69e0df6 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -3999,7 +3999,7 @@ function upgrade_124_to_125() { if (!function_exists("file_notice")) { require_once("notices.inc"); } - file_notice("WirelessSettings", "WEP is no longer supported. It will be disabled on the {$ifname} interface and the interface will be disabled. Please reconfigure the interface."); + file_notice("WirelessSettings", sprintf(gettext("WEP is no longer supported. It will be disabled on the %s interface and the interface will be disabled. Please reconfigure the interface."), $ifname)); unset($config['interfaces'][$ifname]['wireless']['wep']); if (isset($intf['enable'])) { unset($config['interfaces'][$ifname]['enable']); @@ -4209,8 +4209,7 @@ function upgrade_132_to_133() { $p1['encryption-algorithm']['name'] == 'des') { $p1['disabled'] = true; file_notice("IPsec", - "DES is no longer supported, IPsec phase 1 " . - "item '{$p1['descr']}' is being disabled."); + sprintf(gettext("DES is no longer supported, IPsec phase 1 item '%s' is being disabled."), $p1['descr'])); } } } @@ -4227,8 +4226,7 @@ function upgrade_132_to_133() { if ($ealgo['name'] == 'des') { $p2['disabled'] = true; file_notice("IPsec", - "DES is no longer supported, IPsec phase 2 " . - "item '{$p2['descr']}' is being disabled."); + sprintf(gettext("DES is no longer supported, IPsec phase 2 item '%s' is being disabled."), $p2['descr'])); } } } @@ -4273,7 +4271,7 @@ function upgrade_135_to_136() { global $config; if (isset($config['l7shaper'])) { - file_notice("L7shaper", "Layer 7 shaping is no longer supported. Its configuration has been removed."); + file_notice("L7shaper", gettext("Layer 7 shaping is no longer supported. Its configuration has been removed.")); unset($config['l7shaper']); if (is_array($config['filter']['rule'])) { foreach ($config['filter']['rule'] as $idx => $rule) { diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index b3c3242..92149ff 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -277,7 +277,7 @@ function refcount_reference($reference) { refcount_init($reference); $shmid = @shmop_open($reference, "w", 0, 0); if (!$shmid) { - log_error(gettext("Could not open shared memory {$reference}")); + log_error(sprintf(gettext("Could not open shared memory %s"), $reference)); unlock($shm_lck); return; } @@ -302,7 +302,7 @@ function refcount_unreference($reference) { $shmid = @shmop_open($reference, "w", 0, 0); if (!$shmid) { refcount_init($reference); - log_error(gettext("Could not open shared memory {$reference}")); + log_error(sprintf(gettext("Could not open shared memory %s"), $reference)); unlock($shm_lck); return; } @@ -329,7 +329,7 @@ function refcount_read($reference) { /* There is no need for locking. */ $shmid = @shmop_open($reference, "a", 0, 0); if (!$shmid) { - log_error(gettext("Could not open shared memory for read {$reference}")); + log_error(sprintf(gettext("Could not open shared memory for read %s"), $reference)); return -1; } $shm_data = @shmop_read($shmid, 0, 10); diff --git a/src/etc/inc/voucher.inc b/src/etc/inc/voucher.inc index 221e8c5..93c0e93 100644 --- a/src/etc/inc/voucher.inc +++ b/src/etc/inc/voucher.inc @@ -93,23 +93,23 @@ EOF; XML_RPC_encode($execcmd) ); - log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}."); + log_error(sprintf(gettext("Captive Portal Voucher XMLRPC sync data %s."), $url . ":" . $port)); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); $resp = $cli->send($msg, "250"); if (!is_object($resp)) { - $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + $error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url . ":" . $port); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); return false; } elseif ($resp->faultCode()) { - $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + $error = sprintf(gettext('An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %1$s - Code %2$s'), $url . ":" . $port, $resp->faultCode() . ": " . $resp->faultString()); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); return false; } else { - log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + log_error(sprintf(gettext("CaptivePortalVoucherSync XMLRPC reload data success with %s (pfsense.exec_php)."), $url . ":" . $port)); } $toreturn = XML_RPC_Decode($resp->value()); @@ -153,23 +153,23 @@ EOF; XML_RPC_encode($execcmd) ); - log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}."); + log_error(sprintf(gettext("Captive Portal Voucher XMLRPC sync data %s."), $url . ":" . $port)); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); $resp = $cli->send($msg, "250"); if (!is_object($resp)) { - $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + $error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url . ":" . $port); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); return false; } elseif ($resp->faultCode()) { - $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + $error = sprintf(gettext('An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %1$s - Code %2$s'), $url . ":" . $port, $resp->faultCode() . ": " . $resp->faultString()); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); return false; } else { - log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + log_error(sprintf(gettext("CaptivePortalVoucherSync XMLRPC reload data success with %s (pfsense.exec_php)."), $url . ":" . $port)); } $toreturn = XML_RPC_Decode($resp->value()); @@ -212,23 +212,23 @@ EOF; XML_RPC_encode($execcmd) ); - log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}."); + log_error(sprintf(gettext("Captive Portal Voucher XMLRPC sync data %s."), $url . ":" . $port)); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); $resp = $cli->send($msg, "250"); if (!is_object($resp)) { - $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + $error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url . ":" . $port); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); return null; // $timeleft } elseif ($resp->faultCode()) { - $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + $error = sprintf(gettext('An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %1$s - Code %2$s'), $url . ":" . $port, $resp->faultCode() . ": " . $resp->faultString()); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); return null; // $timeleft } else { - log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + log_error(sprintf(gettext("CaptivePortalVoucherSync XMLRPC reload data success with %s (pfsense.exec_php)."), $url . ":" . $port)); } $toreturn = XML_RPC_Decode($resp->value()); if (!is_array($config['voucher'])) { @@ -237,7 +237,7 @@ EOF; if (is_array($toreturn['voucher']) && is_array($toreturn['voucher']['roll'])) { $config['voucher'][$cpzone]['roll'] = $toreturn['voucher']['roll']; - write_config("Captive Portal Voucher database synchronized with {$url}"); + write_config(sprintf(gettext("Captive Portal Voucher database synchronized with %s"), $url)); voucher_configure_zone(true); unset($toreturn['voucher']); } else if (!isset($toreturn['timeleft'])) { @@ -324,11 +324,11 @@ function voucher_expire($voucher_received) { $unsetindexes[] = $cpentry[5]; } } else { - captiveportal_syslog("$voucher ($roll/$nr): not found on any registered Roll"); + captiveportal_syslog(sprintf(gettext('%1$s (%2$s/%3$s): not found on any registered Roll'), $voucher, $roll, $nr)); } } else { // hmm, thats weird ... not what I expected - captiveportal_syslog("$voucher invalid: {$output[0]}!!"); + captiveportal_syslog(sprintf(gettext('%1$s invalid: %2$s!!'), $voucher, $output[0])); } } @@ -415,8 +415,9 @@ function voucher_auth($voucher_received, $test = 0) { foreach ($a_vouchers_received as $voucher) { $v = escapeshellarg($voucher); if (strlen($voucher) < 5) { - $test_result[] = "{$voucher} invalid: Too short!"; - captiveportal_syslog("{$voucher} invalid: Too short!"); + $voucher_err_text = sprintf(gettext("%s invalid: Too short!"), $voucher); + $test_result[] = $voucher_err_text; + captiveportal_syslog($voucher_err_text); $error++; continue; // seems too short to be a voucher! } @@ -452,25 +453,28 @@ function voucher_auth($voucher_received, $test = 0) { $pos = $nr >> 3; // divide by 8 -> octet $mask = 1 << ($nr % 8); if (ord($bitstring[$roll][$pos]) & $mask) { - $test_result[] = "$voucher ($roll/$nr) already used and expired"; - captiveportal_syslog("$voucher ($roll/$nr) already used and expired"); + $voucher_err_text = sprintf(gettext('%1$s (%2$s/%3$s) already used and expired'), $voucher, $roll, $nr); + $test_result[] = $voucher_err_text; + captiveportal_syslog($voucher_err_text); $total_minutes = -1; // voucher expired $error++; } else { // mark bit for this voucher as used $bitstring[$roll][$pos] = chr(ord($bitstring[$roll][$pos]) | $mask); - $test_result[] = "$voucher ($roll/$nr) good for {$minutes_per_roll[$roll]} Minutes"; + $test_result[] = sprintf(gettext('%1$s (%2$s/%3$s) good for %4$s Minutes'), $voucher, $roll, $nr, $minutes_per_roll[$roll]); $total_minutes += $minutes_per_roll[$roll]; } } } else { - $test_result[] = "$voucher ($roll/$nr): not found on any registered Roll"; - captiveportal_syslog("$voucher ($roll/$nr): not found on any registered Roll"); + $voucher_err_text = sprintf(gettext('%1$s (%2$s/%3$s): not found on any registered Roll'), $voucher, $roll, $nr); + $test_result[] = $voucher_err_text; + captiveportal_syslog($voucher_err_text); } } else { // hmm, thats weird ... not what I expected - $test_result[] = "$voucher invalid: $result !!"; - captiveportal_syslog("$voucher invalid: $result !!"); + $voucher_err_text = sprintf(gettext('%1$s invalid: %2$s !!'), $voucher, $result); + $test_result[] = $voucher_err_text; + captiveportal_syslog($voucher_err_text); $error++; } } @@ -647,7 +651,7 @@ function voucher_write_used_db($roll, $vdb) { fwrite($fd, $vdb . "\n"); fclose($fd); } else { - voucher_log(LOG_ERR, sprintf(gettext('cant write %1$s/voucher_%s_used_%2$s.db'), $g['vardb_path'], $cpzone, $roll)); + voucher_log(LOG_ERR, sprintf(gettext('cant write %1$s/voucher_%2$s_used_%3$s.db'), $g['vardb_path'], $cpzone, $roll)); } } @@ -733,7 +737,7 @@ function voucher_read_used_db($roll) { $vdb = trim(fgets($fd)); fclose($fd); } else { - voucher_log(LOG_ERR, sprintf(gettext('cant read %1$s/voucher_%s_used_%2$s.db'), $g['vardb_path'], $cpzone, $roll)); + voucher_log(LOG_ERR, sprintf(gettext('cant read %1$s/voucher_%2$s_used_%3$s.db'), $g['vardb_path'], $cpzone, $roll)); } } return base64_decode($vdb); @@ -805,7 +809,7 @@ function voucher_save_db_to_config_zone() { unlock($voucherlck); - write_config("Syncing vouchers"); + write_config(gettext("Syncing vouchers")); return; } diff --git a/src/etc/inc/vpn.inc b/src/etc/inc/vpn.inc index 57af293..f843239 100644 --- a/src/etc/inc/vpn.inc +++ b/src/etc/inc/vpn.inc @@ -91,62 +91,62 @@ function vpn_logging_cfgtxt() { /* include all configuration functions */ function vpn_ipsec_convert_to_modp($index) { - $convertion = ""; + $conversion = ""; switch ($index) { case '1': - $convertion = "modp768"; + $conversion = "modp768"; break; case '2': - $convertion = "modp1024"; + $conversion = "modp1024"; break; case '5': - $convertion = "modp1536"; + $conversion = "modp1536"; break; case '14': - $convertion = "modp2048"; + $conversion = "modp2048"; break; case '15': - $convertion = "modp3072"; + $conversion = "modp3072"; break; case '16': - $convertion = "modp4096"; + $conversion = "modp4096"; break; case '17': - $convertion = "modp6144"; + $conversion = "modp6144"; break; case '18': - $convertion = "modp8192"; + $conversion = "modp8192"; break; case '19': - $convertion = "ecp256"; + $conversion = "ecp256"; break; case '20': - $convertion = "ecp384"; + $conversion = "ecp384"; break; case '21': - $convertion = "ecp521"; + $conversion = "ecp521"; break; case '22': - $convertion = "modp1024s160"; + $conversion = "modp1024s160"; break; case '23': - $convertion = "modp2048s224"; + $conversion = "modp2048s224"; break; case '24': - $convertion = "modp2048s256"; + $conversion = "modp2048s256"; break; case '28': - $convertion = "ecp256bp"; + $conversion = "ecp256bp"; break; case '29': - $convertion = "ecp384bp"; + $conversion = "ecp384bp"; break; case '30': - $convertion = "ecp512bp"; + $conversion = "ecp512bp"; break; } - return $convertion; + return $conversion; } function vpn_ipsec_configure($restart = false) { @@ -309,7 +309,7 @@ function vpn_ipsec_configure($restart = false) { $ep = ipsec_get_phase1_src($ph1ent); if (!is_ipaddr($ep)) { - log_error("IPsec ERROR: Could not find phase 1 source for connection {$ph1ent['descr']}. Omitting from configuration file."); + log_error(sprintf(gettext("IPsec ERROR: Could not find phase 1 source for connection %s. Omitting from configuration file."), $ph1ent['descr'])); continue; } @@ -338,7 +338,7 @@ function vpn_ipsec_configure($restart = false) { } } if (array_search($rg, $rgmap)) { - log_error("The remote gateway {$rg} already exists on another phase 1 entry"); + log_error(sprintf(gettext("The remote gateway %s already exists on another phase 1 entry"), $rg)); continue; } $rgmap[$ph1ent['remote-gateway']] = $rg; @@ -1403,7 +1403,7 @@ EOD; $ipsecfin .= "\tleftsubnet = " . $leftsubnet_spec[$idx] . "\n"; } } else { - log_error("No phase2 specifications for tunnel with REQID = {$ikeid}"); + log_error(sprintf(gettext("No phase2 specifications for tunnel with REQID = %s"), $ikeid)); } } else { $ipsecfin = "\nconn con{$ph1ent['ikeid']}\n"; diff --git a/src/etc/inc/xmlrpc.inc b/src/etc/inc/xmlrpc.inc index a124341..86e9b45 100644 --- a/src/etc/inc/xmlrpc.inc +++ b/src/etc/inc/xmlrpc.inc @@ -119,7 +119,7 @@ function xmlrpc_auth(&$params) { array_shift($params); unset($params['xmlrpcauth']); - log_error("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']} during sync settings."); + log_error(sprintf(gettext("webConfigurator authentication error for 'admin' from %s during sync settings."), $_SERVER['REMOTE_ADDR'])); return false; } -- cgit v1.1