From 2f8082cdd8619a004980aebdd641518dea117084 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Mon, 23 Feb 2015 11:17:14 -0500 Subject: [PATCH] CRM-13584: installer localisation: added more ts() calls, minor tweaks. --- install/index.php | 211 ++++++++++++++++++++++-------------------- install/template.css | 5 +- install/template.html | 22 +++-- 3 files changed, 127 insertions(+), 111 deletions(-) diff --git a/install/index.php b/install/index.php index cf9cbcfa63..a869383a7e 100644 --- a/install/index.php +++ b/install/index.php @@ -323,9 +323,9 @@ class InstallRequirements { ) { $this->requireMySQLServer($databaseConfig['server'], array( - "MySQL $dbName Configuration", - "Does the server exist", - "Can't find the a MySQL server on '$databaseConfig[server]'", + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Does the server exist?"), + ts("Can't find the a MySQL server on '%1'.", array(1 => $databaseConfig['server'])), $databaseConfig['server'], ) ); @@ -333,27 +333,27 @@ class InstallRequirements { $databaseConfig['username'], $databaseConfig['password'], array( - "MySQL $dbName Configuration", - "Are the access credentials correct", - "That username/password doesn't work", + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Are the access credentials correct?"), + ts("That username/password doesn't work"), ) ) ) { @$this->requireMySQLVersion("5.1", array( - "MySQL $dbName Configuration", - "MySQL version at least 5.1", - "MySQL version 5.1 or higher is required, you only have ", - "MySQL " . mysql_get_server_info(), + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("MySQL version at least %1", array(1 => '5.1')), + ts("MySQL version %1 or higher is required, you are running MySQL %2.", array(1 => '5.1', 2 => mysql_get_server_info())), + ts("MySQL %1", array(1 => mysql_get_server_info())), ) ); $this->requireMySQLAutoIncrementIncrementOne($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], array( - "MySQL $dbName Configuration", - "Is auto_increment_increment set to 1", - "An auto_increment_increment value greater than 1 is not currently supported. Please see issue CRM-7923 for further details and potential workaround.", + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Is auto_increment_increment set to 1"), + ts("An auto_increment_increment value greater than 1 is not currently supported. Please see issue CRM-7923 for further details and potential workaround."), ) ); $this->requireMySQLThreadStack($databaseConfig['server'], @@ -362,8 +362,8 @@ class InstallRequirements { $databaseConfig['database'], self::MINIMUM_THREAD_STACK, array( - "MySQL $dbName Configuration", - "Does MySQL thread_stack meet minimum (" . self::MINIMUM_THREAD_STACK . "k)", + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Does MySQL thread_stack meet minimum (%1k)", array(1 => self::MINIMUM_THREAD_STACK)), "", // "The MySQL thread_stack does not meet minimum " . CRM_Upgrade_Form::MINIMUM_THREAD_STACK . "k. Please update thread_stack in my.cnf.", ) @@ -376,9 +376,9 @@ class InstallRequirements { $databaseConfig['password'], $databaseConfig['database'], array( - "MySQL $dbName Configuration", - "Can I access/create the database", - "I can't create new databases and the database '$databaseConfig[database]' doesn't exist", + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Can I access/create the database?"), + ts("I can't create new databases and the database '%1' doesn't exist.", array(1 => $databaseConfig[database])), ), $onlyRequire ); @@ -388,9 +388,9 @@ class InstallRequirements { $databaseConfig['password'], $databaseConfig['database'], array( - "MySQL $dbName Configuration", - "Can I access/create InnoDB tables in the database", - "Unable to create InnoDB tables. MySQL InnoDB support is required for CiviCRM but is either not available or not enabled in this MySQL database server.", + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Can I access/create InnoDB tables in the database?"), + ts("Unable to create InnoDB tables. MySQL InnoDB support is required for CiviCRM but is either not available or not enabled in this MySQL database server."), ) ); $this->requireMySQLTempTables($databaseConfig['server'], @@ -398,9 +398,9 @@ class InstallRequirements { $databaseConfig['password'], $databaseConfig['database'], array( - "MySQL $dbName Configuration", - 'Can I create temporary tables in the database', - 'Unable to create temporary tables. This MySQL user is missing the CREATE TEMPORARY TABLES privilege.', + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts('Can I create temporary tables in the database?'), + ts('Unable to create temporary tables. This MySQL user is missing the CREATE TEMPORARY TABLES privilege.'), ) ); $this->requireMySQLLockTables($databaseConfig['server'], @@ -408,9 +408,9 @@ class InstallRequirements { $databaseConfig['password'], $databaseConfig['database'], array( - "MySQL $dbName Configuration", - 'Can I create lock tables in the database', - 'Unable to lock tables. This MySQL user is missing the LOCK TABLES privilege.', + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts('Can I create lock tables in the database?'), + ts('Unable to lock tables. This MySQL user is missing the LOCK TABLES privilege.'), ) ); $this->requireMySQLTrigger($databaseConfig['server'], @@ -418,9 +418,9 @@ class InstallRequirements { $databaseConfig['password'], $databaseConfig['database'], array( - "MySQL $dbName Configuration", - 'Can I create triggers in the database', - 'Unable to create triggers. This MySQL user is missing the CREATE TRIGGERS privilege.', + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts('Can I create triggers in the database?'), + ts('Unable to create triggers. This MySQL user is missing the CREATE TRIGGERS privilege.'), ) ); } @@ -436,18 +436,18 @@ class InstallRequirements { $this->errors = NULL; $this->requirePHPVersion('5.3.3', array( - "PHP Configuration", - "PHP5 installed", + ts("PHP Configuration"), + ts("PHP5 installed"), NULL, - "PHP version " . phpversion(), + ts("PHP version %1", array(1 => phpversion())), )); // Check that we can identify the root folder successfully $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . 'README.txt', array( - "File permissions", - "Does the webserver know where files are stored?", - "The webserver isn't letting me identify where files are stored.", + ts("File permissions"), + ts("Does the webserver know where files are stored?"), + ts("The webserver isn't letting me identify where files are stored."), $this->getBaseDir(), ), TRUE @@ -456,9 +456,9 @@ class InstallRequirements { // CRM-6485: make sure the path does not contain PATH_SEPARATOR, as we don’t know how to escape it $this->requireNoPathSeparator( array( - 'File permissions', - 'does the CiviCRM path contain PATH_SEPARATOR?', - 'the ' . $this->getBaseDir() . ' path contains PATH_SEPARATOR (the ' . PATH_SEPARATOR . ' character)', + ts("File permissions"), + ts('Does the CiviCRM path contain PATH_SEPARATOR?'), + ts('The path %1 contains PATH_SEPARATOR (the %2 character).', array(1 => $this->getBaseDir(), 2 => PATH_SEPARATOR)), $this->getBaseDir(), ) ); @@ -467,9 +467,9 @@ class InstallRequirements { foreach ($requiredDirectories as $dir) { $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . $dir, array( - "File permissions", - "$dir folder exists", - "There is no $dir folder", + ts("File permissions"), + ts("Folder '%1' exists?", array(1 => $dir)), + ts("There is no '%1' folder.", array(1 => $dir)), ), TRUE ); } @@ -497,10 +497,12 @@ class InstallRequirements { foreach ($writableDirectories as $dir) { $dirName = CIVICRM_WINDOWS ? $dir : CIVICRM_DIRECTORY_SEPARATOR . $dir; - $this->requireWriteable($dirName, - array("File permissions", "Is the $dir folder writeable?", NULL), - TRUE + $testDetails = array( + ts("File permissions"), + ts("Is the %1 folder writeable?", array(1 => $dir)), + NULL, ); + $this->requireWriteable($dirName, $testDetails, TRUE); } //check for Config.IDS.ini, file may exist in re-install @@ -522,40 +524,44 @@ class InstallRequirements { } if ($webserver == '') { - $webserver = "I can't tell what webserver you are running"; + $webserver = ts("I can't tell what webserver you are running"); } // Check for $_SERVER configuration $this->requireServerVariables(array('SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME'), array( - "Webserver config", - "Recognised webserver", - "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set.", + ts("Webserver config"), + ts("Recognised webserver"), + ts("You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."), )); // Check for MySQL support - $this->requireFunction('mysql_connect', - array("PHP Configuration", "MySQL support", "MySQL support not included in PHP.") - ); + $this->requireFunction('mysql_connect', array( + ts("PHP Configuration"), + ts("MySQL support"), + ts("MySQL support not included in PHP."), + )); // Check for JSON support - $this->requireFunction('json_encode', - array("PHP Configuration", "JSON support", "JSON support not included in PHP.") - ); + $this->requireFunction('json_encode', array( + ts("PHP Configuration"), + ts("JSON support"), + ts("JSON support not included in PHP."), + )); // Check for xcache_isset and emit warning if exists $this->checkXCache(array( - "PHP Configuration", - "XCache compatibility", - "XCache is installed and there are known compatibility issues between XCache and CiviCRM. Consider using an alternative PHP caching mechanism or disable PHP caching altogether.", + ts("PHP Configuration"), + ts("XCache compatibility"), + ts("XCache is installed and there are known compatibility issues between XCache and CiviCRM. Consider using an alternative PHP caching mechanism or disable PHP caching altogether."), )); // Check memory allocation $this->requireMemory(32 * 1024 * 1024, 64 * 1024 * 1024, array( - "PHP Configuration", - "Memory allocated (PHP config option 'memory_limit')", - "CiviCRM needs a minimum of 32M allocated to PHP, but recommends 64M.", + ts("PHP Configuration"), + ts("Memory allocated (PHP config option 'memory_limit')"), + ts("CiviCRM needs a minimum of %1 MB allocated to PHP, but recommends %2 MB.", array(1 => 32, 2 => 64)), ini_get("memory_limit"), ) ); @@ -573,15 +579,15 @@ class InstallRequirements { $mem = $this->getPHPMemory(); if ($mem < $min && $mem > 0) { - $testDetails[2] .= " You only have " . ini_get("memory_limit") . " allocated"; + $testDetails[2] .= " " . ts("You only have %1 allocated", array(1 => ini_get("memory_limit"))); $this->error($testDetails); } elseif ($mem < $recommended && $mem > 0) { - $testDetails[2] .= " You only have " . ini_get("memory_limit") . " allocated"; + $testDetails[2] .= " " . ts("You only have %1 allocated", array(1 => ini_get("memory_limit"))); $this->warning($testDetails); } elseif ($mem == 0) { - $testDetails[2] .= " We can't determine how much memory you have allocated. Install only if you're sure you've allocated at least 20 MB."; + $testDetails[2] .= " " . ts("We can't determine how much memory you have allocated. Install only if you're sure you've allocated at least %1 MB.", array(1 => 32)); $this->warning($testDetails); } } @@ -609,7 +615,7 @@ class InstallRequirements { public function listErrors() { if ($this->errors) { - echo "

The following problems are preventing me from installing CiviCRM:

"; + echo "

" . ts("The following problems are preventing me from installing CiviCRM:") . "

"; foreach ($this->errors as $error) { echo "
  • " . htmlentities($error) . "
  • "; } @@ -693,10 +699,10 @@ class InstallRequirements { if (!$testDetails[2]) { if (!$aboveMinVersion) { - $testDetails[2] = "You need PHP version $minVersion or later, only {$phpVersion} is installed. Please upgrade your server, or ask your web-host to do so."; + $testDetails[2] = ts("You need PHP version %1 or later, only %2 is installed. Please upgrade your server, or ask your web-host to do so.", array(1 => $minVersion, 2 => $phpVersion)); } else { - $testDetails[2] = "PHP version {$phpVersion} is not supported. PHP version earlier than $maxVersion is required. You might want to downgrade your server, or ask your web-host to do so."; + $testDetails[2] = ts("PHP version %1 is not supported. PHP version earlier than %2 is required. You might want to downgrade your server, or ask your web-host to do so.", array(1 => $maxVersion, 2 => $phpVersion)); } } @@ -714,7 +720,7 @@ class InstallRequirements { $filename = $this->getBaseDir() . $filename; } if (!file_exists($filename)) { - $testDetails[2] .= " (file '$filename' not found)"; + $testDetails[2] .= " (" . ts("file '%1' not found", array(1 => $filename)) . ')'; $this->error($testDetails); } } @@ -737,7 +743,7 @@ class InstallRequirements { $this->testing($testDetails); $filename = $this->getBaseDir() . $filename; if (file_exists($filename)) { - $testDetails[2] .= " (file '$filename' found)"; + $testDetails[2] .= " (" . ts("file '%1' found", array(1 => $filename)) . ")"; $this->error($testDetails); } } @@ -778,7 +784,7 @@ class InstallRequirements { if (!isset($testDetails[2])) { $testDetails[2] = NULL; } - $testDetails[2] .= "The user account used by your web-server $name needs to be granted write access to the following directory in order to configure the CiviCRM settings file:\n$filename"; + $testDetails[2] .= ts("The user account used by your web-server %1 needs to be granted write access to the following directory in order to configure the CiviCRM settings file:", array(1 => $name)) . "\n$filename"; $this->error($testDetails); } } @@ -838,7 +844,7 @@ class InstallRequirements { $this->testing($testDetails); if (!mysql_get_server_info()) { - $testDetails[2] = 'Cannot determine the version of MySQL installed. Please ensure at least version 4.1 is installed.'; + $testDetails[2] = ts('Cannot determine the version of MySQL installed. Please ensure at least version %1 is installed.', array(1 => $version)); $this->warning($testDetails); } else { @@ -866,7 +872,7 @@ class InstallRequirements { $this->testing($testDetails); $conn = @mysql_connect($server, $username, $password); if (!$conn) { - $testDetails[2] .= ' Could not determine if mysql has innodb support. Assuming no'; + $testDetails[2] .= ' ' . ts("Could not determine if MySQL has InnoDB support. Assuming no."); $this->error($testDetails); return; } @@ -883,10 +889,10 @@ class InstallRequirements { } } if ($innodb_support) { - $testDetails[3] = 'MySQL server does have innodb support'; + $testDetails[3] = ts('MySQL server does have InnoDB support'); } else { - $testDetails[2] .= ' Could not determine if mysql has innodb support. Assuming no'; + $testDetails[2] .= ' ' . ts('Could not determine if MySQL has InnoDB support. Assuming no'); } } @@ -901,20 +907,20 @@ class InstallRequirements { $this->testing($testDetails); $conn = @mysql_connect($server, $username, $password); if (!$conn) { - $testDetails[2] = 'Could not login to the database.'; + $testDetails[2] = ts('Could not login to the database.'); $this->error($testDetails); return; } if (!@mysql_select_db($database, $conn)) { - $testDetails[2] = 'Could not select the database.'; + $testDetails[2] = ts('Could not select the database.'); $this->error($testDetails); return; } $result = mysql_query('CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)', $conn); if (!$result) { - $testDetails[2] = 'Could not create a temp table.'; + $testDetails[2] = ts('Could not create a temp table.'); $this->error($testDetails); } $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test'); @@ -931,27 +937,27 @@ class InstallRequirements { $this->testing($testDetails); $conn = @mysql_connect($server, $username, $password); if (!$conn) { - $testDetails[2] = 'Could not login to the database.'; + $testDetails[2] = ts('Could not login to the database.'); $this->error($testDetails); return; } if (!@mysql_select_db($database, $conn)) { - $testDetails[2] = 'Could not select the database.'; + $testDetails[2] = ts('Could not select the database.'); $this->error($testDetails); return; } $result = mysql_query('CREATE TABLE civicrm_install_temp_table_test (test text)', $conn); if (!$result) { - $testDetails[2] = 'Could not create a table.'; + $testDetails[2] = ts('Could not create a table in the database.'); $this->error($testDetails); } $result = mysql_query('CREATE TRIGGER civicrm_install_temp_table_test_trigger BEFORE INSERT ON civicrm_install_temp_table_test FOR EACH ROW BEGIN END'); if (!$result) { mysql_query('DROP TABLE civicrm_install_temp_table_test'); - $testDetails[2] = 'Could not create a trigger.'; + $testDetails[2] = ts('Could not create a database trigger.'); $this->error($testDetails); } @@ -971,27 +977,27 @@ class InstallRequirements { $this->testing($testDetails); $conn = @mysql_connect($server, $username, $password); if (!$conn) { - $testDetails[2] = 'Could not login to the database.'; + $testDetails[2] = ts('Could not connect to the database server.'); $this->error($testDetails); return; } if (!@mysql_select_db($database, $conn)) { - $testDetails[2] = 'Could not select the database.'; + $testDetails[2] = ts('Could not select the database.'); $this->error($testDetails); return; } $result = mysql_query('CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)', $conn); if (!$result) { - $testDetails[2] = 'Could not create a table.'; + $testDetails[2] = ts('Could not create a table in the database.'); $this->error($testDetails); return; } $result = mysql_query('LOCK TABLES civicrm_install_temp_table_test WRITE', $conn); if (!$result) { - $testDetails[2] = 'Could not obtain a write lock for the table.'; + $testDetails[2] = ts('Could not obtain a write lock for the database table.'); $this->error($testDetails); $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test'); return; @@ -999,7 +1005,7 @@ class InstallRequirements { $result = mysql_query('UNLOCK TABLES', $conn); if (!$result) { - $testDetails[2] = 'Could not release the lock for the table.'; + $testDetails[2] = ts('Could not release the lock for the database table.'); $this->error($testDetails); $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test'); return; @@ -1018,21 +1024,21 @@ class InstallRequirements { $this->testing($testDetails); $conn = @mysql_connect($server, $username, $password); if (!$conn) { - $testDetails[2] = 'Could not connect to the database server.'; + $testDetails[2] = ts('Could not connect to the database server.'); $this->error($testDetails); return; } $result = mysql_query("SHOW variables like 'auto_increment_increment'", $conn); if (!$result) { - $testDetails[2] = 'Could not query database server variables.'; + $testDetails[2] = ts('Could not query database server variables.'); $this->error($testDetails); return; } else { $values = mysql_fetch_row($result); if ($values[1] == 1) { - $testDetails[3] = 'MySQL server auto_increment_increment is 1'; + $testDetails[3] = ts('MySQL server auto_increment_increment is 1'); } else { $this->error($testDetails); @@ -1052,26 +1058,26 @@ class InstallRequirements { $this->testing($testDetails); $conn = @mysql_connect($server, $username, $password); if (!$conn) { - $testDetails[2] = 'Could not login to the database.'; + $testDetails[2] = ts('Could not connect to the database server.'); $this->error($testDetails); return; } if (!@mysql_select_db($database, $conn)) { - $testDetails[2] = 'Could not select the database.'; + $testDetails[2] = ts('Could not select the database.'); $this->error($testDetails); return; } $result = mysql_query("SHOW VARIABLES LIKE 'thread_stack'", $conn); // bytes => kb if (!$result) { - $testDetails[2] = 'Could not query thread_stack.'; + $testDetails[2] = ts('Could not get information about the thread_stack of the database.'); $this->error($testDetails); } else { $values = mysql_fetch_row($result); if ($values[1] < (1024 * $minValueKB)) { - $testDetails[2] = 'MySQL "thread_stack" is ' . ($values[1] / 1024) . 'k'; + $testDetails[2] = ts('MySQL "thread_stack" is %1 kb', array(1 => ($values[1] / 1024))); $this->error($testDetails); } } @@ -1101,16 +1107,16 @@ class InstallRequirements { $okay = "Database '$database' exists"; } elseif ($onlyRequire) { - $testDetails[2] = "The database: '$database' does not exist"; + $testDetails[2] = ts("The database: '%1' does not exist.", array(1 => $database)); $this->error($testDetails); return; } else { if (@mysql_query("CREATE DATABASE $database")) { - $okay = "Able to create a new database"; + $okay = ts("Able to create a new database."); } else { - $testDetails[2] .= " (user '$username' doesn't have CREATE DATABASE permissions.)"; + $testDetails[2] .= " (" . ts("user '%1' doesn't have CREATE DATABASE permissions.", array(1 => $username)) . ")"; $this->error($testDetails); return; } @@ -1137,7 +1143,7 @@ class InstallRequirements { return TRUE; } else { - $testDetails[2] = " (the following PHP variables are missing: " . implode(", ", $missing) . ")"; + $testDetails[2] = " (" . ts('the following PHP variables are missing: %1', array(1 => implode(", ", $missing))) . ")"; $this->error($testDetails); } } @@ -1175,7 +1181,7 @@ class InstallRequirements { $section = $testDetails[0]; $test = $testDetails[1]; - $message = "OK"; + $message = ts("OK"); if (isset($testDetails[3])) { $message .= " ($testDetails[3])"; } @@ -1291,11 +1297,11 @@ class Installer extends InstallRequirements { $output .= ''; $output .= ''; $output .= ''; - $output .= 'CiviCRM Installed'; + $output .= '' . ts('CiviCRM Installed') . ''; $output .= ''; $output .= ''; $output .= ''; - $output .= '

    CiviCRM has been successfully installed

    '; + $output .= '

    ' . ts('CiviCRM has been successfully installed') . '

    '; $output .= '