From e8c516a01dd02375d0ea5a480e4e4bdccbd27fb8 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 18 Feb 2016 18:04:34 +0545 Subject: Internationalize etc inc i through s --- src/etc/inc/ipsec.inc | 140 ++++++++++++++++++++++++------------------ src/etc/inc/notices.inc | 2 +- src/etc/inc/openvpn.inc | 58 ++++++++--------- src/etc/inc/pfsense-utils.inc | 76 +++++++++++------------ src/etc/inc/pkg-utils.inc | 20 +++--- src/etc/inc/rrd.inc | 20 +++--- src/etc/inc/service-utils.inc | 4 +- src/etc/inc/services.inc | 28 ++++----- src/etc/inc/shaper.inc | 14 ++--- src/etc/inc/system.inc | 18 +++--- 10 files changed, 200 insertions(+), 180 deletions(-) diff --git a/src/etc/inc/ipsec.inc b/src/etc/inc/ipsec.inc index 2b7ff4d..53b735b 100644 --- a/src/etc/inc/ipsec.inc +++ b/src/etc/inc/ipsec.inc @@ -54,40 +54,53 @@ /* IPsec defines */ global $ipsec_loglevels; -$ipsec_loglevels = array("dmn" => "Daemon", "mgr" => "SA Manager", "ike" => "IKE SA", "chd" => "IKE Child SA", - "job" => "Job Processing", "cfg" => "Configuration backend", "knl" => "Kernel Interface", - "net" => "Networking", "asn" => "ASN encoding", "enc" => "Message encoding", - "imc" => "Integrity checker", "imv" => "Integrity Verifier", "pts" => "Platform Trust Service", - "tls" => "TLS handler", "esp" => "IPsec traffic", "lib" => "StrongSwan Lib"); +$ipsec_loglevels = array( + "dmn" => gettext("Daemon"), + "mgr" => gettext("SA Manager"), + "ike" => gettext("IKE SA"), + "chd" => gettext("IKE Child SA"), + "job" => gettext("Job Processing"), + "cfg" => gettext("Configuration backend"), + "knl" => gettext("Kernel Interface"), + "net" => gettext("Networking"), + "asn" => gettext("ASN encoding"), + "enc" => gettext("Message encoding"), + "imc" => gettext("Integrity checker"), + "imv" => gettext("Integrity Verifier"), + "pts" => gettext("Platform Trust Service"), + "tls" => gettext("TLS handler"), + "esp" => gettext("IPsec traffic"), + "lib" => gettext("StrongSwan Lib") +); global $ipsec_log_sevs; $ipsec_log_sevs = array( - '-1' => 'Silent', - '0' => 'Audit', - '1' => 'Control', - '2' => 'Diag', - '3' => 'Raw', - '4' => 'Highest' + '-1' => gettext('Silent'), + '0' => gettext('Audit'), + '1' => gettext('Control'), + '2' => gettext('Diag'), + '3' => gettext('Raw'), + '4' => gettext('Highest') ); global $ipsec_log_cats; $ipsec_log_cats = array( - "dmn" => "Daemon", - "mgr" => "SA Manager", - "ike" => "IKE SA", - "chd" => "IKE Child SA", - "job" => "Job Processing", - "cfg" => "Configuration backend", - "knl" => "Kernel Interface", - "net" => "Networking", - "asn" => "ASN encoding", - "enc" => "Message encoding", - "imc" => "Integrity checker", - "imv" => "Integrity Verifier", - "pts" => "Platform Trust Service", - "tls" => "TLS handler", - "esp" => "IPsec traffic", - "lib" => "StrongSwan Lib" + "dmn" => gettext("Daemon"), + "mgr" => gettext("SA Manager"), + "ike" => gettext("IKE SA"), + "chd" => gettext("IKE Child SA"), + "job" => gettext("Job Processing"), + "cfg" => gettext("Configuration backend"), + "knl" => gettext("Kernel Interface"), + "net" => gettext("Networking"), + "asn" => gettext("ASN encoding"), + "enc" => gettext("Message encoding"), + "imc" => gettext("Integrity checker"), + "imv" => gettext("Integrity Verifier"), + "pts" => gettext("Platform Trust Service"), + "tls" => gettext("TLS handler"), + "esp" => gettext("IPsec traffic"), + "lib" => gettext("StrongSwan Lib") ); global $my_identifier_list; @@ -98,7 +111,8 @@ $my_identifier_list = array( 'user_fqdn' => array('desc' => gettext('User distinguished name'), 'mobile' => true), 'asn1dn' => array('desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true), 'keyid tag' => array('desc' => gettext('KeyID tag'), 'mobile' => true), - 'dyn_dns' => array('desc' => gettext('Dynamic DNS'), 'mobile' => true)); + 'dyn_dns' => array('desc' => gettext('Dynamic DNS'), 'mobile' => true) +); global $peer_identifier_list; $peer_identifier_list = array( @@ -108,19 +122,21 @@ $peer_identifier_list = array( 'fqdn' => array('desc' => gettext('Distinguished name'), 'mobile' => true), 'user_fqdn' => array('desc' => gettext('User distinguished name'), 'mobile' => true), 'asn1dn' => array('desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true), - 'keyid tag' => array('desc' =>gettext('KeyID tag'), 'mobile' => true)); + 'keyid tag' => array('desc' =>gettext('KeyID tag'), 'mobile' => true) +); global $ipsec_idhandling; $ipsec_idhandling = array( 'yes' => 'YES', 'no' => 'NO', 'never' => 'NEVER', 'keep' => 'KEEP' - ); +); global $p1_ealgos; $p1_ealgos = array( 'aes' => array('name' => 'AES', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), 'blowfish' => array('name' => 'Blowfish', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), '3des' => array('name' => '3DES'), - 'cast128' => array('name' => 'CAST128')); + 'cast128' => array('name' => 'CAST128') +); global $p2_ealgos; $p2_ealgos = array( @@ -130,7 +146,8 @@ $p2_ealgos = array( 'aes256gcm' => array('name' => 'AES256-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), 'blowfish' => array('name' => 'Blowfish', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), '3des' => array('name' => '3DES'), - 'cast128' => array('name' => 'CAST128')); + 'cast128' => array('name' => 'CAST128') +); global $p1_halgos; $p1_halgos = array( @@ -175,49 +192,52 @@ $p2_halgos = array( global $p1_authentication_methods; $p1_authentication_methods = array( - 'hybrid_rsa_server' => array('name' => 'Hybrid RSA + Xauth', 'mobile' => true), - 'xauth_rsa_server' => array('name' => 'Mutual RSA + Xauth', 'mobile' => true), - 'xauth_psk_server' => array('name' => 'Mutual PSK + Xauth', 'mobile' => true), - 'eap-tls' => array('name' => 'EAP-TLS', 'mobile' => true), - 'eap-radius' => array('name' => 'EAP-RADIUS', 'mobile' => true), - 'eap-mschapv2' => array('name' => 'EAP-MSChapv2', 'mobile' => true), - 'rsasig' => array('name' => 'Mutual RSA', 'mobile' => false), - 'pre_shared_key' => array('name' => 'Mutual PSK', 'mobile' => false)); + 'hybrid_rsa_server' => array('name' => gettext('Hybrid RSA + Xauth'), 'mobile' => true), + 'xauth_rsa_server' => array('name' => gettext('Mutual RSA + Xauth'), 'mobile' => true), + 'xauth_psk_server' => array('name' => gettext('Mutual PSK + Xauth'), 'mobile' => true), + 'eap-tls' => array('name' => gettext('EAP-TLS'), 'mobile' => true), + 'eap-radius' => array('name' => gettext('EAP-RADIUS'), 'mobile' => true), + 'eap-mschapv2' => array('name' => gettext('EAP-MSChapv2'), 'mobile' => true), + 'rsasig' => array('name' => gettext('Mutual RSA'), 'mobile' => false), + 'pre_shared_key' => array('name' => gettext('Mutual PSK'), 'mobile' => false) +); global $ipsec_preshared_key_type; $ipsec_preshared_key_type = array( 'PSK' => 'PSK', 'EAP' => 'EAP' - ); +); global $p2_modes; $p2_modes = array( - 'tunnel' => 'Tunnel IPv4', - 'tunnel6' => 'Tunnel IPv6', - 'transport' => 'Transport'); + 'tunnel' => gettext('Tunnel IPv4'), + 'tunnel6' => gettext('Tunnel IPv6'), + 'transport' => gettext('Transport') +); global $p2_protos; $p2_protos = array( 'esp' => 'ESP', - 'ah' => 'AH'); + 'ah' => 'AH' +); global $p2_pfskeygroups; $p2_pfskeygroups = array( - 0 => 'off', - 1 => '1 (768 bit)', - 2 => '2 (1024 bit)', - 5 => '5 (1536 bit)', - 14 => '14 (2048 bit)', - 15 => '15 (3072 bit)', - 16 => '16 (4096 bit)', - 17 => '17 (6144 bit)', - 18 => '18 (8192 bit)', - 19 => '19 (nist ecp256)', - 20 => '20 (nist ecp384)', - 21 => '21 (nist ecp521)', - 28 => '28 (brainpool ecp256)', - 29 => '29 (brainpool ecp384)', - 30 => '30 (brainpool ecp512)' + 0 => gettext('off'), + 1 => gettext('1 (768 bit)'), + 2 => gettext('2 (1024 bit)'), + 5 => gettext('5 (1536 bit)'), + 14 => gettext('14 (2048 bit)'), + 15 => gettext('15 (3072 bit)'), + 16 => gettext('16 (4096 bit)'), + 17 => gettext('17 (6144 bit)'), + 18 => gettext('18 (8192 bit)'), + 19 => gettext('19 (nist ecp256)'), + 20 => gettext('20 (nist ecp384)'), + 21 => gettext('21 (nist ecp521)'), + 28 => gettext('28 (brainpool ecp256)'), + 29 => gettext('29 (brainpool ecp384)'), + 30 => gettext('30 (brainpool ecp512)') ); function ipsec_enabled() { diff --git a/src/etc/inc/notices.inc b/src/etc/inc/notices.inc index d70518b..86413ba 100644 --- a/src/etc/inc/notices.inc +++ b/src/etc/inc/notices.inc @@ -106,7 +106,7 @@ function file_notice($id, $notice, $category = "General", $url = "", $priority = } fwrite($queueout, serialize($queue)); fclose($queueout); - log_error("New alert found: $notice"); + log_error(sprintf(gettext("New alert found: %s"), $notice)); /* soekris */ if (file_exists("/dev/led/error")) { exec("/bin/echo 1 > /dev/led/error"); diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc index 6a4f1df..9456192 100644 --- a/src/etc/inc/openvpn.inc +++ b/src/etc/inc/openvpn.inc @@ -74,10 +74,10 @@ $openvpn_dev_mode = array("tun", "tap"); global $openvpn_verbosity_level; $openvpn_verbosity_level = array( - 0 => "none", - 1 => "default", + 0 => gettext("none"), + 1 => gettext("default"), 2 => "2", - 3 => "3 (recommended)", + 3 => gettext("3 (recommended)"), 4 => "4", 5 => "5", 6 => "6", @@ -107,11 +107,11 @@ $openvpn_dh_lengths = array( global $openvpn_cert_depths; $openvpn_cert_depths = array( - 1 => "One (Client+Server)", - 2 => "Two (Client+Intermediate+Server)", - 3 => "Three (Client+2xIntermediate+Server)", - 4 => "Four (Client+3xIntermediate+Server)", - 5 => "Five (Client+4xIntermediate+Server)" + 1 => gettext("One (Client+Server)"), + 2 => gettext("Two (Client+Intermediate+Server)"), + 3 => gettext("Three (Client+2xIntermediate+Server)"), + 4 => gettext("Four (Client+3xIntermediate+Server)"), + 5 => gettext("Five (Client+4xIntermediate+Server)") ); global $openvpn_server_modes; @@ -214,7 +214,7 @@ function openvpn_build_cert_list($include_none = false, $prioritize_server_certs global $a_cert; if ($include_none) { - $list = array('' => 'None (Username and/or Password required)'); + $list = array('' => gettext('None (Username and/or Password required)')); } else { $list = array(); } @@ -222,8 +222,8 @@ function openvpn_build_cert_list($include_none = false, $prioritize_server_certs $non_server_list = array(); if ($prioritize_server_certs) { - $list[' '] = "===== Server Certificates ====="; - $non_server_list[' '] = "===== Non-Server Certificates ====="; + $list[' '] = gettext("===== Server Certificates ====="); + $non_server_list[' '] = gettext("===== Non-Server Certificates ====="); } foreach ($a_cert as $cert) { @@ -233,18 +233,18 @@ function openvpn_build_cert_list($include_none = false, $prioritize_server_certs $purpose = cert_get_purpose($cert['crt'], true); if ($purpose['server'] == "Yes") { - $properties[] = "Server: Yes"; + $properties[] = gettext("Server: Yes"); } elseif ($prioritize_server_certs) { - $properties[] = "Server: NO"; + $properties[] = gettext("Server: NO"); } if ($ca) { - $properties[] = "CA: {$ca['descr']}"; + $properties[] = sprintf(gettext("CA: %s"), $ca['descr']); } if (cert_in_use($cert['refid'])) { - $properties[] = "In Use"; + $properties[] = gettext("In Use"); } if (is_cert_revoked($cert)) { - $properties[] = "Revoked"; + $properties[] = gettext("Revoked"); } if (!empty($properties)) { @@ -426,7 +426,7 @@ function openvpn_get_digestlist() { } function openvpn_get_engines() { - $openssl_engines = array('none' => 'No Hardware Crypto Acceleration'); + $openssl_engines = array('none' => gettext('No Hardware Crypto Acceleration')); exec("/usr/bin/openssl engine -t -c", $openssl_engine_output); $openssl_engine_output = implode("\n", $openssl_engine_output); $openssl_engine_output = preg_replace("/\\n\\s+/", "|", $openssl_engine_output); @@ -492,7 +492,7 @@ function openvpn_validate_cidr($value, $name, $multiple = false, $ipproto = "ipv $networks = explode(',', $value); if (!$multiple && (count($networks) > 1)) { - return sprintf(gettext("The field '%s' must contain a single valid %s CIDR range."), $name, $ipproto); + return sprintf(gettext("The field '%1\$s' must contain a single valid %2\$s CIDR range."), $name, $ipproto); } foreach ($networks as $network) { @@ -507,7 +507,7 @@ function openvpn_validate_cidr($value, $name, $multiple = false, $ipproto = "ipv } if ($error) { - return sprintf(gettext("The field '%s' must contain only valid %s CIDR range(s) separated by commas."), $name, $ipproto); + return sprintf(gettext("The field '%1\$s' must contain only valid %2\$s CIDR range(s) separated by commas."), $name, $ipproto); } else { return false; } @@ -1113,7 +1113,7 @@ function openvpn_restart($mode, $settings) { while (posix_kill($pid, 0)) { usleep(250000); if ($i > 10) { - log_error("OpenVPN ID $mode_id PID $pid still running, killing."); + log_error(sprintf(gettext('OpenVPN ID %1$s PID %2$s still running, killing.'), $mode_id, $pid)); posix_kill($pid, SIGKILL); usleep(500000); } @@ -1329,9 +1329,9 @@ function openvpn_resync_all($interface = "") { } */ if ($interface <> "") { - log_error("Resyncing OpenVPN instances for interface " . convert_friendly_interface_to_friendly_descr($interface) . "."); + log_error(sprintf(gettext("Resyncing OpenVPN instances for interface %s."), convert_friendly_interface_to_friendly_descr($interface))); } else { - log_error("Resyncing OpenVPN instances."); + log_error(gettext("Resyncing OpenVPN instances.")); } if (is_array($config['openvpn']['openvpn-server'])) { @@ -1368,7 +1368,7 @@ function openvpn_resync_gwgroup($gwgroupname = "") { if (is_array($config['openvpn']['openvpn-server'])) { foreach ($config['openvpn']['openvpn-server'] as & $settings) { if ($gwgroupname == $settings['interface']) { - log_error("Resyncing OpenVPN for gateway group " . $gwgroupname . " server " . $settings["description"] . "."); + log_error(sprintf(gettext('Resyncing OpenVPN for gateway group %1$s server %2$s.'), $gwgroupname, $settings["description"])); openvpn_resync('server', $settings); } } @@ -1377,7 +1377,7 @@ function openvpn_resync_gwgroup($gwgroupname = "") { if (is_array($config['openvpn']['openvpn-client'])) { foreach ($config['openvpn']['openvpn-client'] as & $settings) { if ($gwgroupname == $settings['interface']) { - log_error("Resyncing OpenVPN for gateway group " . $gwgroupname . " client " . $settings["description"] . "."); + log_error(sprintf(gettext('Resyncing OpenVPN for gateway group %1$s client %2$s.'), $gwgroupname, $settings["description"])); openvpn_resync('client', $settings); } } @@ -1386,7 +1386,7 @@ function openvpn_resync_gwgroup($gwgroupname = "") { // Note: no need to resysnc Client Specific (csc) here, as changes to the OpenVPN real interface do not effect these. } else { - log_error("openvpn_resync_gwgroup called with null gwgroup parameter."); + log_error(gettext("openvpn_resync_gwgroup called with null gwgroup parameter.")); } } @@ -1487,8 +1487,8 @@ function openvpn_get_server_status($server, $socket) { } else { $conn = array(); $conn['common_name'] = "[error]"; - $conn['remote_host'] = "Unable to contact daemon"; - $conn['virtual_addr'] = "Service not running?"; + $conn['remote_host'] = gettext("Unable to contact daemon"); + $conn['virtual_addr'] = gettext("Service not running?"); $conn['bytes_recv'] = 0; $conn['bytes_sent'] = 0; $conn['connect_time'] = 0; @@ -1615,8 +1615,8 @@ function openvpn_get_client_status($client, $socket) { } else { $DisplayNote=true; - $client['remote_host'] = "Unable to contact daemon"; - $client['virtual_addr'] = "Service not running?"; + $client['remote_host'] = gettext("Unable to contact daemon"); + $client['virtual_addr'] = gettext("Service not running?"); $client['bytes_recv'] = 0; $client['bytes_sent'] = 0; $client['connect_time'] = 0; diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 77d5008..5090a94 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -543,7 +543,7 @@ function WakeOnLan($addr, $mac) { } $e = socket_sendto($s, $msg, strlen($msg), 0, $addr, 2050); socket_close($s); - log_error(sprintf(gettext('Magic Packet sent (%1$s) to {%2$s} MAC=%3$s'), $e, $addr, $mac)); + log_error(sprintf(gettext('Magic Packet sent (%1$s) to (%2$s) MAC=%3$s'), $e, $addr, $mac)); return true; } @@ -1586,7 +1586,7 @@ function load_crypto() { } if (!empty($config['system']['crypto_hardware']) && !is_module_loaded($config['system']['crypto_hardware'])) { - log_error("Loading {$config['system']['crypto_hardware']} cryptographic accelerator module."); + log_error(sprintf(gettext("Loading %s cryptographic accelerator module."), $config['system']['crypto_hardware'])); mwexec("/sbin/kldload {$config['system']['crypto_hardware']}"); } } @@ -1603,7 +1603,7 @@ function load_thermal_hardware() { } if (!empty($config['system']['thermal_hardware']) && !is_module_loaded($config['system']['thermal_hardware'])) { - log_error("Loading {$config['system']['thermal_hardware']} thermal monitor module."); + log_error(sprintf(gettext("Loading %s thermal monitor module."), $config['system']['thermal_hardware'])); mwexec("/sbin/kldload {$config['system']['thermal_hardware']}"); } } @@ -1679,7 +1679,7 @@ function download_file($url, $destination, $verify_ssl = true, $connect_timeout if ($http_code == 200) { return true; } else { - log_error("Download file failed with status code $http_code. URL: $url"); + log_error(sprintf(gettext('Download file failed with status code %1$s. URL: %2$s'), $http_code, $url)); unlink_if_exists($destination); return false; } @@ -1734,7 +1734,7 @@ function download_file_with_progress_bar($url, $destination, $verify_ssl = true, if ($http_code == 200) { return true; } else { - log_error("Download file failed with status code $http_code. URL: $url"); + log_error(sprintf(gettext('Download file failed with status code %1$s. URL: %2$s'), $http_code, $url)); unlink_if_exists($destination); return false; } @@ -1931,7 +1931,7 @@ function parse_aliases_file($filename, $type = "url", $max_items = -1) { $fd = @fopen($filename, 'r'); if (!$fd) { - log_error(gettext("Could not process aliases from alias: {$filename}")); + log_error(sprintf(gettext("Could not process aliases from alias: %s"), $filename)); return null; } $items = array(); @@ -2022,13 +2022,13 @@ function process_alias_tgz($temp_filename) { /* foreach through all extracted files and build up aliases file */ $fd = @fopen("{$temp_filename}/aliases", "w"); if (!$fd) { - log_error(gettext("Could not open {$temp_filename}/aliases for writing!")); + log_error(sprintf(gettext("Could not open %s/aliases for writing!"), $temp_filename)); return false; } foreach ($files_to_process as $f2p) { $tmpfd = @fopen($f2p, 'r'); if (!$tmpfd) { - log_error(gettext("The following file could not be read {$f2p} from {$temp_filename}")); + log_error(sprintf(gettext('The following file could not be read %1$s from %2$s'), $f2p, $temp_filename)); continue; } while (($tmpbuf = fread($tmpfd, 65536)) !== FALSE) { @@ -2837,7 +2837,7 @@ function huawei_rssi_to_string($rssi) { } function huawei_mode_to_string($mode, $submode) { - $modes[0] = "None"; + $modes[0] = gettext("None"); $modes[1] = "AMPS"; $modes[2] = "CDMA"; $modes[3] = "GSM/GPRS"; @@ -2845,7 +2845,7 @@ function huawei_mode_to_string($mode, $submode) { $modes[5] = "WCDMA"; $modes[6] = "GPS"; - $submodes[0] = "No Service"; + $submodes[0] = gettext("No Service"); $submodes[1] = "GSM"; $submodes[2] = "GPRS"; $submodes[3] = "EDGE"; @@ -2855,28 +2855,28 @@ function huawei_mode_to_string($mode, $submode) { $submodes[7] = "HSDPA+HSUPA"; $submodes[8] = "TD-SCDMA"; $submodes[9] = "HSPA+"; - $string = "{$modes[$mode]}, {$submodes[$submode]} Mode"; + $string = "{$modes[$mode]}, {$submodes[$submode]} " . gettext("Mode"); return $string; } function huawei_service_to_string($state) { - $modes[0] = "No"; - $modes[1] = "Restricted"; - $modes[2] = "Valid"; - $modes[3] = "Restricted Regional"; - $modes[4] = "Powersaving"; - $string = "{$modes[$state]} Service"; + $modes[0] = gettext("No Service"); + $modes[1] = gettext("Restricted Service"); + $modes[2] = gettext("Valid Service"); + $modes[3] = gettext("Restricted Regional Service"); + $modes[4] = gettext("Powersaving Service"); + $string = $modes[$state]; return $string; } function huawei_simstate_to_string($state) { - $modes[0] = "Invalid SIM/locked"; - $modes[1] = "Valid SIM"; - $modes[2] = "Invalid SIM CS"; - $modes[3] = "Invalid SIM PS"; - $modes[4] = "Invalid SIM CS/PS"; - $modes[255] = "Missing SIM"; - $string = "{$modes[$state]} State"; + $modes[0] = gettext("Invalid SIM/locked State"); + $modes[1] = gettext("Valid SIM State"); + $modes[2] = gettext("Invalid SIM CS State"); + $modes[3] = gettext("Invalid SIM PS State"); + $modes[4] = gettext("Invalid SIM CS/PS State"); + $modes[255] = gettext("Missing SIM State"); + $string = $modes[$state]; return $string; } @@ -2885,8 +2885,8 @@ function zte_rssi_to_string($rssi) { } function zte_mode_to_string($mode, $submode) { - $modes[0] = "No Service"; - $modes[1] = "Limited Service"; + $modes[0] = gettext("No Service"); + $modes[1] = gettext("Limited Service"); $modes[2] = "GPRS"; $modes[3] = "GSM"; $modes[4] = "UMTS"; @@ -2897,25 +2897,25 @@ function zte_mode_to_string($mode, $submode) { $submodes[1] = "PS_ONLY"; $submodes[2] = "CS_PS"; $submodes[3] = "CAMPED"; - $string = "{$modes[$mode]}, {$submodes[$submode]} Mode"; + $string = "{$modes[$mode]}, {$submodes[$submode]} " . gettext("Mode"); return $string; } -function zte_service_to_string($state) { - $modes[0] = "Initializing"; - $modes[1] = "Network Lock error"; - $modes[2] = "Network Locked"; - $modes[3] = "Unlocked or correct MCC/MNC"; - $string = "{$modes[$state]} Service"; +function zte_service_to_string($service) { + $modes[0] = gettext("Initializing Service"); + $modes[1] = gettext("Network Lock error Service"); + $modes[2] = gettext("Network Locked Service"); + $modes[3] = gettext("Unlocked or correct MCC/MNC Service"); + $string = $modes[$service]; return $string; } function zte_simstate_to_string($state) { - $modes[0] = "No action"; - $modes[1] = "Network lock"; - $modes[2] = "(U)SIM card lock"; - $modes[3] = "Network Lock and (U)SIM card Lock"; - $string = "{$modes[$state]} State"; + $modes[0] = gettext("No action State"); + $modes[1] = gettext("Network lock State"); + $modes[2] = gettext("(U)SIM card lock State"); + $modes[3] = gettext("Network Lock and (U)SIM card Lock State"); + $string = $modes[$state]; return $string; } diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc index daceefb..b0d8568 100644 --- a/src/etc/inc/pkg-utils.inc +++ b/src/etc/inc/pkg-utils.inc @@ -554,10 +554,10 @@ function sync_package($package_name) { if (file_exists($include_file)) { require_once($include_file); } else { - log_error("Reinstalling package {$package['name']} because its include file({$include_file}) is missing!"); + log_error(sprintf(gettext('Reinstalling package %1$s because its include file(%2$s) is missing!'), $package['name'], $include_file)); uninstall_package($package['name']); if (install_package($package['name']) != 0) { - log_error("Reinstalling package {$package['name']} failed. Take appropriate measures!!!"); + log_error(sprintf(gettext("Reinstalling package %s failed. Take appropriate measures!!!"), $package['name'])); return; } if (file_exists($include_file)) { @@ -667,7 +667,7 @@ function install_package_xml($package_name) { $to_output = gettext("overwrite!") . "\n"; } unlink_if_exists('/conf/needs_package_sync'); - write_config("Intermediate config write during package install for {$pkg_info['name']}."); + write_config(sprintf(gettext("Intermediate config write during package install for %s."), $pkg_info['name'])); conf_mount_ro(); update_status($to_output); @@ -704,7 +704,7 @@ function install_package_xml($package_name) { } else { pkg_debug("Missing include {$pkg_config['include_file']}\n"); $missing_include = true; - update_status("Include " . basename($pkg_config['include_file']) . " is missing!\n"); + update_status(sprintf(gettext("Include %s is missing!"), basename($pkg_config['include_file'])) . "\n"); uninstall_package($package_name); write_config($changedesc); @@ -862,7 +862,7 @@ function delete_package_xml($package_name, $when = "post-deinstall") { * XXX: Otherwise inclusion of config.inc again invalidates actions taken. * Same is done during installation. */ - write_config("Intermediate config write during package removal for {$package_name}."); + write_config(sprintf(gettext("Intermediate config write during package removal for %s."), $package_name)); /* * If a require exists, include it. this will @@ -878,7 +878,7 @@ function delete_package_xml($package_name, $when = "post-deinstall") { } else { pkg_debug("Missing include {$pkg_config['include_file']}\n"); $missing_include = true; - update_status("Include file " . basename($pkg_config['include_file']) . " could not be found for inclusion.\n"); + update_status(sprintf(gettext("Include file %s could not be found for inclusion."), basename($pkg_config['include_file'])) . "\n"); } } /* ermal @@ -901,14 +901,14 @@ function delete_package_xml($package_name, $when = "post-deinstall") { eval_once($pkg_config['custom_php_deinstall_command']); update_status(gettext("done.") . "\n"); } else { - update_status("\nNot executing custom deinstall hook because an include is missing.\n"); + update_status("\n". gettext("Not executing custom deinstall hook because an include is missing.") . "\n"); } } } /* syslog */ $need_syslog_restart = false; if (is_array($pkg_info['logging']) && $pkg_info['logging']['logfilename'] <> "") { - update_status("Syslog entries... "); + update_status(gettext("Syslog entries... ")); @unlink("{$g['varlog_path']}/{$pkg_info['logging']['logfilename']}"); update_status("done.\n"); $need_syslog_restart = true; @@ -919,7 +919,7 @@ function delete_package_xml($package_name, $when = "post-deinstall") { update_status(gettext("Configuration... ")); unset($config['installedpackages']['package'][$pkgid]); update_status(gettext("done.") . "\n"); - write_config("Removed {$package_name} package.\n"); + write_config(sprintf(gettext("Removed %s package."), $package_name)); } /* remove package entry from /etc/syslog.conf if needed */ @@ -1003,7 +1003,7 @@ function stop_packages() { global $config, $g; - log_error("Stopping all packages."); + log_error(gettext("Stopping all packages.")); $rcfiles = glob(RCFILEPREFIX . "*.sh"); if (!$rcfiles) { diff --git a/src/etc/inc/rrd.inc b/src/etc/inc/rrd.inc index ff1d3e1..29411aa 100644 --- a/src/etc/inc/rrd.inc +++ b/src/etc/inc/rrd.inc @@ -98,7 +98,7 @@ function restore_rrd() { unset($rrdrestore); $_gb = exec("cd /;LANG=C /usr/bin/tar -tf {$g['cf_conf_path']}/rrd.tgz", $rrdrestore, $rrdreturn); if ($rrdreturn != 0) { - log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n"); + log_error(sprintf(gettext('RRD restore failed exited with %1$s, the error is: %2$s'), $rrdreturn, $rrdrestore)); return; } foreach ($rrdrestore as $xml_file) { @@ -109,12 +109,12 @@ function restore_rrd() { file_put_contents("{$g['tmp_path']}/rrd_restore", $xml_file); $_gb = exec("cd /;LANG=C /usr/bin/tar -xf {$g['cf_conf_path']}/rrd.tgz -T {$g['tmp_path']}/rrd_restore"); if (!file_exists("/{$xml_file}")) { - log_error("Could not extract {$xml_file} RRD xml file from archive!"); + log_error(sprintf(gettext("Could not extract %s RRD xml file from archive!"), $xml_file)); continue; } $_gb = exec("$rrdtool restore -f '/{$xml_file}' '{$rrd_file}'", $output, $status); if ($status) { - log_error("rrdtool restore -f '{$xml_file}' '{$rrd_file}' failed returning {$status}."); + log_error(sprintf(gettext("rrdtool restore -f '%1\$s' '%2\$s' failed returning %3\$s."), $xml_file, $rrd_file, $status)); continue; } unset($output); @@ -512,17 +512,17 @@ function enable_rrd_graphing() { switch ($altq->GetBwscale()) { case "Gb": $factor = 1024 * 1024 * 1024; - break; + break; case "Mb": - $factor = 1024 * 1024; - break; + $factor = 1024 * 1024; + break; case "Kb": - $factor = 1024; - break; + $factor = 1024; + break; case "b": default: - $factor = 1; - break; + $factor = 1; + break; } $qbandwidth = $altq->GetBandwidth() * $factor; if ($qbandwidth <= 0) { diff --git a/src/etc/inc/service-utils.inc b/src/etc/inc/service-utils.inc index 24b69f2..99a7285 100644 --- a/src/etc/inc/service-utils.inc +++ b/src/etc/inc/service-utils.inc @@ -299,7 +299,7 @@ function get_services() { $pconfig = array(); $pconfig['name'] = "captiveportal"; $pconfig['zone'] = $zone; - $pconfig['description'] = gettext("Captive Portal") . ": ".htmlspecialchars($setting['zone']); + $pconfig['description'] = gettext("Captive Portal") . ": " . htmlspecialchars($setting['zone']); $services[] = $pconfig; } } @@ -387,7 +387,7 @@ function get_services() { $pconfig['mode'] = $mode; $pconfig['id'] = $id; $pconfig['vpnid'] = $setting['vpnid']; - $pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']); + $pconfig['description'] = gettext("OpenVPN") . " " . $mode . ": " . htmlspecialchars($setting['description']); $services[] = $pconfig; } } diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 5cb55ff..e07601d 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -354,7 +354,7 @@ function services_radvd_configure($blacklist = array()) { /* write radvd.conf */ if (!@file_put_contents("{$g['varetc_path']}/radvd.conf", $radvdconf)) { - log_error("Error: cannot open radvd.conf in services_radvd_configure().\n"); + log_error(gettext("Error: cannot open radvd.conf in services_radvd_configure().")); if (platform_booting()) { printf("Error: cannot open radvd.conf in services_radvd_configure().\n"); } @@ -371,7 +371,7 @@ function services_radvd_configure($blacklist = array()) { /* we need to shut down the radvd cleanly, it will send out the prefix * information with a lifetime of 0 to notify clients of a (possible) new prefix */ if (isvalidpid("{$g['varrun_path']}/radvd.pid")) { - log_error("Shutting down Router Advertisment daemon cleanly"); + log_error(gettext("Shutting down Router Advertisment daemon cleanly")); killbypid("{$g['varrun_path']}/radvd.pid"); @unlink("{$g['varrun_path']}/radvd.pid"); } @@ -1216,7 +1216,7 @@ function services_dhcpdv6_configure($blacklist = array()) { exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/dhcp6leases.tgz 2>&1", $dhcprestore, $dhcpreturn); $dhcprestore = implode(" ", $dhcprestore); if ($dhcpreturn <> 0) { - log_error("DHCP leases v6 restore failed exited with $dhcpreturn, the error is: $dhcprestore\n"); + log_error(sprintf(gettext('DHCP leases v6 restore failed exited with %1$s, the error is: %2$s'), $dhcpreturn, $dhcprestore)); } } } @@ -1678,7 +1678,7 @@ function services_dhcrelay_configure() { */ $srvips = explode(",", $dhcrelaycfg['server']); if (!is_array($srvips)) { - log_error("No destination IP has been configured!"); + log_error(gettext("No destination IP has been configured!")); return; } @@ -1751,7 +1751,7 @@ function services_dhcrelay_configure() { /* fire up dhcrelay */ if (empty($dhcrelayifs)) { - log_error("No suitable interface found for running dhcrelay!"); + log_error(gettext("No suitable interface found for running dhcrelay!")); return; /* XXX */ } @@ -1875,7 +1875,7 @@ function services_dhcrelay6_configure() { /* fire up dhcrelay */ if (empty($dhcrelayifs) || empty($srvifaces)) { - log_error("No suitable interface found for running dhcrelay -6!"); + log_error(gettext("No suitable interface found for running dhcrelay -6!")); return; /* XXX */ } @@ -2237,7 +2237,7 @@ read := "{$config['snmpd']['rocommunity']}" EOD; -/* No docs on what write strings do there for disable for now. +/* No docs on what write strings do there so disable for now. if (isset($config['snmpd']['rwenable']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])) { $snmpdconf .= << $maxCacheAgeSecs) || $forced) { $upinst .= "update delete {$dnsupdate['host']}. A\n"; $upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} A {$wanip}\n"; - $notify_text .= sprintf(gettext("DynDNS updated IP Address (A) for {$dnsupdate['host']} on %s (%s) to %s"), convert_real_interface_to_friendly_descr($if), $if, $wanip) . "\n"; + $notify_text .= sprintf(gettext('DynDNS updated IP Address (A) for %1$s on %2$s (%3$s) to %4$s'), $dnsupdate['host'], convert_real_interface_to_friendly_descr($if), $if, $wanip) . "\n"; @file_put_contents($cacheFile, "{$wanip}|{$currentTime}"); - log_error("phpDynDNS: updating cache file {$cacheFile}: {$wanip}"); + log_error(sprintf(gettext('phpDynDNS: updating cache file %1$s: %2$s'), $cacheFile, $wanip)); $need_update = true; } else { - log_error("phpDynDNS: Not updating {$dnsupdate['host']} A record because the IP address has not changed."); + log_error(sprintf(gettext("phpDynDNS: Not updating %s A record because the IP address has not changed."), $dnsupdate['host'])); } } else { @unlink($cacheFile); @@ -2519,12 +2519,12 @@ EOD; if (($wanipv6 != $cachedipv6) || (($currentTime - $cacheTimev6) > $maxCacheAgeSecs) || $forced) { $upinst .= "update delete {$dnsupdate['host']}. AAAA\n"; $upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} AAAA {$wanipv6}\n"; - $notify_text .= sprintf(gettext("DynDNS updated IPv6 Address (AAAA) for {$dnsupdate['host']} on %s (%s) to %s"), convert_real_interface_to_friendly_descr($if), $if, $wanipv6) . "\n"; + $notify_text .= sprintf(gettext('DynDNS updated IPv6 Address (AAAA) for %1$s on %2$s (%3$s) to %4$s'), $dnsupdate['host'], convert_real_interface_to_friendly_descr($if), $if, $wanipv6) . "\n"; @file_put_contents("{$cacheFile}.ipv6", "{$wanipv6}|{$currentTime}"); - log_error("phpDynDNS: updating cache file {$cacheFile}.ipv6: {$wanipv6}"); + log_error(sprintf(gettext('phpDynDNS: updating cache file %1$s.ipv6: %2$s'), $cacheFile, $wanipv6)); $need_update = true; } else { - log_error("phpDynDNS: Not updating {$dnsupdate['host']} AAAA record because the IPv6 address has not changed."); + log_error(sprintf(gettext("phpDynDNS: Not updating %s AAAA record because the IPv6 address has not changed."), $dnsupdate['host'])); } } else { @unlink("{$cacheFile}.ipv6"); diff --git a/src/etc/inc/shaper.inc b/src/etc/inc/shaper.inc index 4637250..ad2ec7a 100644 --- a/src/etc/inc/shaper.inc +++ b/src/etc/inc/shaper.inc @@ -530,7 +530,7 @@ class altq_root_queue { $q->ReadConfig($queue); $q->validate_input($queue, $input_errors); if (count($input_errors)) { - log_error("SHAPER: could not create queue " . $q->GetQname() . " on interface {$interface} because: " . print_r($input_errors, true)); + log_error(sprintf(gettext('SHAPER: could not create queue %1$s on interface %2$s because: %3$s'), $q->GetQname(), $interface, print_r($input_errors, true))); return $q; } @@ -667,7 +667,7 @@ class altq_root_queue { } if ($default == false) { - $error = "SHAPER: no default queue specified for interface ". $this->GetInterface() . ". The interface queue will be enforced as default."; + $error = sprintf(gettext("SHAPER: no default queue specified for interface %s."), $this->GetInterface()) . " " . gettext("The interface queue will be enforced as default."); file_notice("Shaper", $error, "Error occurred", ""); unset($error); return "\n"; @@ -1168,10 +1168,10 @@ class priq_queue { shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors); if ($data['bandwidth'] && (!is_numeric($data['bandwidth']))) { - $input_errors[] = "Bandwidth must be an integer."; + $input_errors[] = gettext("Bandwidth must be an integer."); } if ($data['bandwidth'] < 0) { - $input_errors[] = "Bandwidth cannot be negative."; + $input_errors[] = gettext("Bandwidth cannot be negative."); } if ($data['priority'] && (!is_numeric($data['priority']) || ($data['priority'] < 1) || ($data['priority'] > 15))) { @@ -1700,7 +1700,7 @@ class hfsc_queue extends priq_queue { $q->ReadConfig($qname); $q->validate_input($qname, $input_errors); if (count($input_errors)) { - log_error("SHAPER: could not create queue " . $q->GetQname() . " on interface {$interface} because: " . print_r($input_errors, true)); + log_error(sprintf(gettext('SHAPER: could not create queue %1$s on interface %2$s because: %3$s'), $q->GetQname(), $interface, print_r($input_errors, true))); return $q; } @@ -2527,7 +2527,7 @@ class cbq_queue extends priq_queue { $q->ReadConfig($qname); $q->validate_input($qname, $input_errors); if (count($input_errors)) { - log_error("SHAPER: could not create queue " . $q->GetQname() . " on interface {$interface} because: " . print_r($input_errors, true)); + log_error(sprintf(gettext('SHAPER: could not create queue %1$s on interface %2$s because: %3$s'), $q->GetQname(), $interface, print_r($input_errors, true))); return $q; } switch ($q->GetBwscale()) { @@ -3466,7 +3466,7 @@ class dnpipe_class extends dummynet_class { $q->ReadConfig($queue); $q->validate_input($queue, $input_errors); if (count($input_errors)) { - log_error("SHAPER: could not create queue " . $q->GetQname() . " on interface {$interface} because: " . print_r($input_errors, true)); + log_error(sprintf(gettext('SHAPER: could not create queue %1$s on interface %2$s because: %3$s'), $q->GetQname(), $interface, print_r($input_errors, true))); return $q; } $number = dnqueue_find_nextnumber(); diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 21f166b..631ab68 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -450,7 +450,7 @@ function system_hosts_generate() { } $fd = fopen("{$g['varetc_path']}/hosts", "w"); if (!$fd) { - log_error("Error: cannot open hosts file in system_hosts_generate().\n"); + log_error(gettext("Error: cannot open hosts file in system_hosts_generate().")); return 1; } fwrite($fd, $hosts); @@ -600,7 +600,7 @@ function system_routing_configure($interface = "") { foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) { if (($olsrd['enabledyngw'] == "on") && ($olsrd['enable'] == "on")) { $dont_add_route = true; - log_error(sprintf(gettext("Not adding default route because OLSR dynamic gateway is enabled."))); + log_error(gettext("Not adding default route because OLSR dynamic gateway is enabled.")); break; } } @@ -628,7 +628,7 @@ function system_routing_configure($interface = "") { if (!empty($interface) && $interface != $interfacegw) { ; } else if (is_ipaddrv4($gatewayip)) { - log_error("ROUTING: setting default route to $gatewayip"); + log_error(sprintf(gettext("ROUTING: setting default route to %s"), $gatewayip)); mwexec("/sbin/route change -inet default " . escapeshellarg($gatewayip)); } @@ -639,7 +639,7 @@ function system_routing_configure($interface = "") { if (is_linklocal($gatewayipv6) && !strpos($gatewayipv6, '%')) { $ifscope = "%{$defaultifv6}"; } - log_error("ROUTING: setting IPv6 default route to {$gatewayipv6}{$ifscope}"); + log_error(sprintf(gettext("ROUTING: setting IPv6 default route to %s"), $gatewayipv6 . $ifscope)); mwexec("/sbin/route change -inet6 default " . escapeshellarg("{$gatewayipv6}{$ifscope}")); } } @@ -1093,11 +1093,11 @@ function system_webgui_create_certificate() { $config['cert'] = array(); } $a_cert =& $config['cert']; - log_error("Creating SSL Certificate for this host"); + log_error(gettext("Creating SSL Certificate for this host")); $cert = array(); $cert['refid'] = uniqid(); - $cert['descr'] = gettext("webConfigurator default ({$cert['refid']})"); + $cert['descr'] = sprintf(gettext("webConfigurator default (%s)"), $cert['refid']); $dn = array( 'countryName' => "US", @@ -1109,7 +1109,7 @@ function system_webgui_create_certificate() { $old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warnings directly to a page screwing menu tab */ if (!cert_create($cert, null, 2048, 2000, $dn, "self-signed", "sha256")) { while ($ssl_err = openssl_error_string()) { - log_error("Error creating WebGUI Certificate: openssl library returns: " . $ssl_err); + log_error(sprintf(gettext("Error creating WebGUI Certificate: openssl library returns: %s"), $ssl_err)); } error_reporting($old_err_level); return null; @@ -1118,7 +1118,7 @@ function system_webgui_create_certificate() { $a_cert[] = $cert; $config['system']['webgui']['ssl-certref'] = $cert['refid']; - write_config(gettext("Generated new self-signed HTTPS certificate ({$cert['refid']})")); + write_config(sprintf(gettext("Generated new self-signed HTTPS certificate (%s)"), $cert['refid'])); return $cert; } @@ -1809,7 +1809,7 @@ function system_ntp_configure($start_ntpd=true) { /* open configuration for writing or bail */ if (!@file_put_contents("{$g['varetc_path']}/ntpd.conf", $ntpcfg)) { - log_error("Could not open {$g['varetc_path']}/ntpd.conf for writing"); + log_error(sprintf(gettext("Could not open %s/ntpd.conf for writing"), $g['varetc_path'])); return; } -- cgit v1.1