Commit ecfbc27f authored by catch's avatar catch

Issue #1838310 by ParisLiakos, Jose Reyero: Remove st(), get_t() and for good.

parent a10b792f
......@@ -1361,11 +1361,6 @@ function bootstrap_hooks() {
* Translators can then rearrange the string as necessary for the language
* (e.g., in Spanish, it might be "blog de @name").
*
* @section sec_alt_funcs_install Use During Installation Phase
* During the Drupal installation phase, some resources used by t() wil not be
* available to code that needs localization. See st() and get_t() for
* alternatives.
*
* @param $string
* A string containing the English string to translate.
* @param $args
......@@ -1382,8 +1377,6 @@ function bootstrap_hooks() {
* @return
* The translated string.
*
* @see st()
* @see get_t()
* @see format_string()
* @ingroup sanitization
*/
......@@ -2392,38 +2385,6 @@ function drupal_installation_attempted() {
return isset($GLOBALS['install_state']) && empty($GLOBALS['install_state']['installation_finished']);
}
/**
* Returns the name of the proper localization function.
*
* get_t() exists to support localization for code that might run during
* the installation phase, when some elements of the system might not have
* loaded.
*
* This would include implementations of hook_install(), which could run
* during the Drupal installation phase, and might also be run during
* non-installation time, such as while installing the module from the the
* module administration page.
*
* Example usage:
* @code
* $t = get_t();
* $translated = $t('translate this');
* @endcode
*
* Use t() if your code will never run during the Drupal installation phase.
* Use st() if your code will only run during installation and never any other
* time. Use get_t() if your code could run in either circumstance.
*
* @todo Remove this in favor of t().
*
* @see t()
* @see st()
* @ingroup sanitization
*/
function get_t() {
return 't';
}
/**
* Initializes all the defined language types and sets the default langcode.
*/
......
......@@ -1348,9 +1348,6 @@ function drupal_redirect_form($form_state) {
* theming, and hook_form_alter functions.
*/
function _form_validate(&$elements, &$form_state, $form_id = NULL) {
// Also used in the installer, pre-database setup.
$t = get_t();
// Recurse through all children.
foreach (element_children($elements) as $key) {
if (isset($elements[$key]) && $elements[$key]) {
......@@ -1364,7 +1361,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
if (isset($elements['#needs_validation'])) {
// Verify that the value is not longer than #maxlength.
if (isset($elements['#maxlength']) && drupal_strlen($elements['#value']) > $elements['#maxlength']) {
form_error($elements, $t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value']))));
form_error($elements, t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value']))));
}
if (isset($elements['#options']) && isset($elements['#value'])) {
......@@ -1378,7 +1375,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
$value = in_array($elements['#type'], array('checkboxes', 'tableselect')) ? array_keys($elements['#value']) : $elements['#value'];
foreach ($value as $v) {
if (!isset($options[$v])) {
form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
form_error($elements, t('An illegal choice has been detected. Please contact the site administrator.'));
watchdog('form', 'Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
}
}
......@@ -1397,7 +1394,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
form_set_value($elements, NULL, $form_state);
}
elseif (!isset($options[$elements['#value']])) {
form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
form_error($elements, t('An illegal choice has been detected. Please contact the site administrator.'));
watchdog('form', 'Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
}
}
......@@ -1480,7 +1477,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
// constructors are encouraged to set #title anyway, and then set
// #title_display to 'invisible'. This improves accessibility.
elseif (isset($elements['#title'])) {
form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
form_error($elements, t('!name field is required.', array('!name' => $elements['#title'])));
}
else {
form_error($elements);
......@@ -3177,13 +3174,12 @@ function theme_checkboxes($variables) {
* This is used as a pre render function for checkboxes and radios.
*/
function form_pre_render_conditional_form_element($element) {
$t = get_t();
// Set the element's title attribute to show #title as a tooltip, if needed.
if (isset($element['#title']) && $element['#title_display'] == 'attribute') {
$element['#attributes']['title'] = $element['#title'];
if (!empty($element['#required'])) {
// Append an indication that this field is required.
$element['#attributes']['title'] .= ' (' . $t('Required') . ')';
$element['#attributes']['title'] .= ' (' . t('Required') . ')';
}
}
......@@ -4759,11 +4755,9 @@ function theme_form_element($variables) {
* @ingroup themeable
*/
function theme_form_required_marker($variables) {
// This is also used in the installer, pre-database setup.
$t = get_t();
$attributes = array(
'class' => 'form-required',
'title' => $t('This field is required.'),
'title' => t('This field is required.'),
);
return '<abbr' . new Attribute($attributes) . '>*</abbr>';
}
......@@ -4793,8 +4787,6 @@ function theme_form_required_marker($variables) {
*/
function theme_form_element_label($variables) {
$element = $variables['element'];
// This is also used in the installer, pre-database setup.
$t = get_t();
// If title and required marker are both empty, output no label.
if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
......@@ -4820,7 +4812,7 @@ function theme_form_element_label($variables) {
$attributes['for'] = $element['#id'];
}
return '<label' . new Attribute($attributes) . '>' . $t('!title!required', array('!title' => $title, '!required' => $required)) . '</label>';
return '<label' . new Attribute($attributes) . '>' . t('!title!required', array('!title' => $title, '!required' => $required)) . '</label>';
}
/**
......@@ -5029,8 +5021,6 @@ function batch_set($batch_definition) {
}
// Base and default properties for the batch set.
// Use get_t() to allow batches during installation.
$t = get_t();
$init = array(
'sandbox' => array(),
'results' => array(),
......@@ -5039,10 +5029,10 @@ function batch_set($batch_definition) {
'elapsed' => 0,
);
$defaults = array(
'title' => $t('Processing'),
'init_message' => $t('Initializing.'),
'progress_message' => $t('Completed @current of @total.'),
'error_message' => $t('An error has occurred.'),
'title' => t('Processing'),
'init_message' => t('Initializing.'),
'progress_message' => t('Completed @current of @total.'),
'error_message' => t('An error has occurred.'),
'css' => array(),
);
$batch_set = $init + $batch_definition + $defaults;
......@@ -5132,8 +5122,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
if ($batch['progressive']) {
// Now that we have a batch id, we can generate the redirection link in
// the generic error message.
$t = get_t();
$batch['error_message'] = $t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
$batch['error_message'] = t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
// Clear the way for the drupal_goto() redirection to the batch processing
// page, by saving and unsetting the 'destination', if there is any.
......
This diff is collapsed.
......@@ -9,8 +9,6 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\StringTranslation\TranslationManager;
use Drupal\Core\StringTranslation\Translator\CustomStrings;
/**
* Requirement severity -- Informational message only.
......@@ -600,10 +598,10 @@ function drupal_verify_profile($install_state) {
$modules[] = '<span class="admin-missing">' . drupal_ucfirst($module) . '</span>';
}
$requirements['required_modules'] = array(
'title' => st('Required modules'),
'value' => st('Required modules not found.'),
'title' => t('Required modules'),
'value' => t('Required modules not found.'),
'severity' => REQUIREMENT_ERROR,
'description' => st('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: !modules', array('!modules' => implode(', ', $modules))),
'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: !modules', array('!modules' => implode(', ', $modules))),
);
}
return $requirements;
......@@ -930,45 +928,6 @@ function drupal_requirements_url($severity) {
return drupal_current_script_url($query);
}
/**
* Translates a string when some systems are not available.
*
* Used during the install process, when database, theme, and localization
* system is possibly not yet available.
*
* Use t() if your code will never run during the Drupal installation phase.
* Use st() if your code will only run during installation and never any other
* time. Use get_t() if your code could run in either circumstance.
*
* @see t()
* @see get_t()
* @ingroup sanitization
*/
function st($string, array $args = array(), array $options = array()) {
global $install_state;
static $install_translation;
// This may be invoked before the container has been initialized.
$container = Drupal::getContainer();
if ($container && $container->has('translation')) {
// Since the container is properly initialized, we can use standard translation.
return t($string, $args, $options);
}
elseif (drupal_installation_attempted() && isset($install_state['parameters']['langcode'])) {
// The translation service is not there yet, use a temporary one.
if (!isset($install_translation)) {
$install_translation = new TranslationManager();
foreach (array(new CustomStrings(), install_file_translation_service()) as $translator) {
$install_translation->addTranslator($translator);
}
$install_translation->setDefaultLangcode($install_state['parameters']['langcode']);
}
return $install_translation->translate($string, $args, $options);
}
// Just return an untraslated string.
return format_string($string, $args);
}
/**
* Checks an installation profile's requirements.
*
......
......@@ -119,7 +119,6 @@ function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine
* @ingroup themeable
*/
function theme_task_list($variables) {
$t = get_t();
$items = $variables['items'];
$active = $variables['active'];
......@@ -130,12 +129,12 @@ function theme_task_list($variables) {
foreach ($items as $k => $item) {
if ($active == $k) {
$class = 'active';
$status = '(' . $t('active') . ')';
$status = '(' . t('active') . ')';
$done = FALSE;
}
else {
$class = $done ? 'done' : '';
$status = $done ? '(' . $t('done') . ')' : '';
$status = $done ? '(' . t('done') . ')' : '';
}
$output .= '<li';
$output .= ($class ? ' class="' . $class . '"' : '') . '>';
......
......@@ -12,13 +12,10 @@
* Returns Unicode library status and errors.
*/
function unicode_requirements() {
// Ensure translations don't break during installation.
$t = get_t();
$libraries = array(
Unicode::STATUS_SINGLEBYTE => $t('Standard PHP'),
Unicode::STATUS_MULTIBYTE => $t('PHP Mbstring Extension'),
Unicode::STATUS_ERROR => $t('Error'),
Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
Unicode::STATUS_ERROR => t('Error'),
);
$severities = array(
Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
......@@ -29,30 +26,30 @@ function unicode_requirements() {
$library = Unicode::getStatus();
$requirements['unicode'] = array(
'title' => $t('Unicode library'),
'title' => t('Unicode library'),
'value' => $libraries[$library],
'severity' => $severities[$library],
);
$t_args = array('@url' => 'http://www.php.net/mbstring');
switch ($failed_check) {
case 'mb_strlen':
$requirements['unicode']['description'] = $t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', $t_args);
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', $t_args);
break;
case 'mbstring.func_overload':
$requirements['unicode']['description'] = $t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
$requirements['unicode']['description'] = t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
break;
case 'mbstring.encoding_translation':
$requirements['unicode']['description'] = $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
break;
case 'mbstring.http_input':
$requirements['unicode']['description'] = $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
break;
case 'mbstring.http_output':
$requirements['unicode']['description'] = $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
$requirements['unicode']['description'] = t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', $t_args);
break;
}
......
......@@ -280,7 +280,6 @@ private function readLine() {
'%uri' => $this->getURI(),
'%line' => $this->_line_number,
);
$t = get_t();
// Trim away the linefeed. \\n might appear at the end of the string if
// another line continuing the same string follows. We can remove that.
......@@ -306,7 +305,7 @@ private function readLine() {
}
else {
// A comment following any other context is a syntax error.
$this->_errors[] = $t('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
return FALSE;
}
return;
......@@ -316,7 +315,7 @@ private function readLine() {
if ($this->_context != 'MSGID') {
// A plural form can only be added to an msgid directly.
$this->_errors[] = $t('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
return FALSE;
}
......@@ -327,7 +326,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The plural form must be wrapped in quotes.
$this->_errors[] = $t('The translation stream %uri contains a syntax error on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains a syntax error on line %line.', $log_vars);
return FALSE;
}
......@@ -354,7 +353,7 @@ private function readLine() {
}
elseif ($this->_context == 'MSGID') {
// We are currently already in the context, meaning we passed an id with no data.
$this->_errors[] = $t('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
return FALSE;
}
......@@ -365,7 +364,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The message id must be wrapped in quotes.
$this->_errors[] = $t('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
return FALSE;
}
......@@ -383,7 +382,7 @@ private function readLine() {
}
elseif (!empty($this->_current_item['msgctxt'])) {
// A context cannot apply to another context.
$this->_errors[] = $t('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
return FALSE;
}
......@@ -394,7 +393,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The context string must be quoted.
$this->_errors[] = $t('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
return FALSE;
}
......@@ -412,13 +411,13 @@ private function readLine() {
($this->_context != 'MSGSTR_ARR')) {
// Plural message strings must come after msgid, msgxtxt,
// msgid_plural, or other msgstr[] entries.
$this->_errors[] = $t('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
return FALSE;
}
// Ensure the plurality is terminated.
if (strpos($line, ']') === FALSE) {
$this->_errors[] = $t('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
return FALSE;
}
......@@ -433,7 +432,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The string must be quoted.
$this->_errors[] = $t('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
return FALSE;
}
if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) {
......@@ -450,7 +449,7 @@ private function readLine() {
if (($this->_context != 'MSGID') && ($this->_context != 'MSGCTXT')) {
// Strings are only valid within an id or context scope.
$this->_errors[] = $t('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
return FALSE;
}
......@@ -461,7 +460,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// The string must be quoted.
$this->_errors[] = $t('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
return FALSE;
}
......@@ -476,7 +475,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line);
if ($quoted === FALSE) {
// This string must be quoted.
$this->_errors[] = $t('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
return FALSE;
}
......@@ -506,7 +505,7 @@ private function readLine() {
}
else {
// No valid context to append to.
$this->_errors[] = $t('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
return FALSE;
}
return;
......@@ -519,7 +518,7 @@ private function readLine() {
$this->_current_item = array();
}
elseif ($this->_context != 'COMMENT') {
$this->_errors[] = $t('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
$this->_errors[] = t('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
return FALSE;
}
}
......
......@@ -27,7 +27,7 @@ class Tasks extends InstallTasks {
* Returns a human-readable name string for MySQL and equivalent databases.
*/
public function name() {
return st('MySQL, MariaDB, or equivalent');
return t('MySQL, MariaDB, or equivalent');
}
/**
......@@ -70,13 +70,13 @@ protected function connect() {
catch (DatabaseNotFoundException $e) {
// Still no dice; probably a permission issue. Raise the error to the
// installer.
$this->fail(st('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
$this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
}
}
else {
// Database connection failed for some other reason than the database
// not existing.
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist or does the database user have sufficient privileges to create the database?</li><li>Have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
$this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist or does the database user have sufficient privileges to create the database?</li><li>Have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
return FALSE;
}
}
......
......@@ -34,7 +34,7 @@ public function __construct() {
}
public function name() {
return st('PostgreSQL');
return t('PostgreSQL');
}
public function minimumVersion() {
......@@ -84,13 +84,13 @@ protected function connect() {
catch (DatabaseNotFoundException $e) {
// Still no dice; probably a permission issue. Raise the error to the
// installer.
$this->fail(st('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
$this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
}
}
else {
// Database connection failed for some other reason than the database
// not existing.
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
$this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
return FALSE;
}
}
......@@ -103,7 +103,7 @@ protected function connect() {
protected function checkEncoding() {
try {
if (db_query('SHOW server_encoding')->fetchField() == 'UTF8') {
$this->pass(st('Database is encoded in UTF-8'));
$this->pass(t('Database is encoded in UTF-8'));
}
else {
$replacements = array(
......@@ -113,11 +113,11 @@ protected function checkEncoding() {
);
$text = 'The %driver database must use %encoding encoding to work with Drupal.';
$text .= 'Recreate the database with %encoding encoding. See !link for more details.';
$this->fail(st($text, $replacements));
$this->fail(t($text, $replacements));
}
}
catch (\Exception $e) {
$this->fail(st('Drupal could not determine the encoding of the database was set to UTF-8'));
$this->fail(t('Drupal could not determine the encoding of the database was set to UTF-8'));
}
}
......@@ -236,4 +236,3 @@ function initializeDatabase() {
}
}
}
......@@ -16,7 +16,7 @@ class Tasks extends InstallTasks {
protected $pdoDriver = 'sqlite';
public function name() {
return st('SQLite');
return t('SQLite');
}
/**
......@@ -35,8 +35,8 @@ public function getFormOptions($database) {
unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);
// Make the text more accurate for SQLite.
$form['database']['#title'] = st('Database file');
$form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
$form['database']['#title'] = t('Database file');
$form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
$default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
$form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
return $form;
......@@ -86,17 +86,16 @@ protected function connect() {
catch (DatabaseNotFoundException $e) {
// Still no dice; probably a permission issue. Raise the error to the
// installer.
$this->fail(st('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
$this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
}
}
else {
// Database connection failed for some other reason than the database
// not existing.
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
$this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
return FALSE;
}
}
return TRUE;
}
}
......@@ -137,7 +137,7 @@ public function runTasks() {
}
}
else {
throw new TaskException(st("Failed to run all tasks against the database server. The task %task wasn't found.", array('%task' => $task['function'])));
throw new TaskException(t("Failed to run all tasks against the database server. The task %task wasn't found.", array('%task' => $task['function'])));
}
}
}
......@@ -166,7 +166,7 @@ protected function connect() {
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (\Exception $e) {
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
$this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
return FALSE;
}
return TRUE;
......@@ -178,10 +178,10 @@ protected function connect() {
protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) {
try {
db_query($query);
$this->pass(st($pass));
$this->pass(t($pass));
}
catch (\Exception $e) {
$this->fail(st($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name())));
$this->fail(t($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name())));
return !$fatal;
}
}
......@@ -191,7 +191,7 @@ protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) {
*/
protected function checkEngineVersion() {
if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion(), '<')) {
$this->fail(st("The database version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion())));
$this->fail(t("The database version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion())));
}
}
......@@ -207,16 +207,16 @@ protected function checkEngineVersion() {
public function getFormOptions($database) {
$form['database'] = array(
'#type' => 'textfield',
'#title' => st('Database name'),
'#title' => t('Database name'),
'#default_value' => empty($database['database']) ? '' : $database['database'],
'#size' => 45,
'#required' => TRUE,
'#description' => st('The name of the database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_distribution_name())),
'#description' => t('The name of the database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_distribution_name())),
);
$form['username'] = array(
'#type' => 'textfield',
'#title' => st('Database username'),
'#title' => t('Database username'),
'#default_value' => empty($database['username']) ? '' : $database['username'],
'#required' => TRUE,
'#size' => 45,
......@@ -224,7 +224,7 @@ public function getFormOptions($database) {
$form['password'] = array(
'#type' => 'password',
'#title' => st('Database password'),
'#title' => t('Database password'),
'#default_value' => empty($database['password']) ? '' : $database['password'],
'#required' => FALSE,
'#size' => 45,
......@@ -232,9 +232,9 @@ public function getFormOptions($database) {
$form['advanced_options'] = array(
'#type' => 'details',
'#title' => st('Advanced options'),
'#title' => t('Advanced options'),
'#collapsed' => TRUE,
'#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider."),
'#description' => t("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider."),
'#weight' => 10,
);
......@@ -242,32 +242,32 @@ public function getFormOptions($database) {
$db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_';
$form['advanced_options']['db_prefix'] = array(
'#type' => 'textfield',
'#title' => st('Table prefix'),
'#title' => t('Table prefix'),
'#default_value' => '',
'#size' => 45,
'#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_distribution_name(), '%prefix' => $db_prefix)),
'#description' => t('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_distribution_name(), '%prefix' => $db_prefix)),
'#weight' => 10,
);
$form['advanced_options']['host'] = array(
'#type' => 'textfield',
'#title' => st('Database host'),
'#title' => t('Database host'),
'#default_value' => empty($database['host']) ? 'localhost' : $database['host'],
'#size' => 45,
// Hostnames can be 255 characters long.
'#maxlength' => 255,
'#required' => TRUE,
'#description' => st('If your database is located on a different server, change this.'),
'#description' => t('If your database is located on a different server, change this.'),
);
$form['advanced_options']['port'] = array(
'#type' => 'textfield',
'#title' => st('Database port'),
'#title' => t('Database port'),
'#default_value' => empty($database['port']) ? '' : $database['port'],<