Patch #334283 by Damien Tournoud: add support of translation contexts (based on standard gettext msgctxt). From: Damien Tournoud --- common.inc | 38 ++++++++-------- locale.inc | 107 +++++++++++++++++++++++++++++++--------------- locale/locale.install | 8 +++ locale/locale.module | 16 +++---- locale/locale.test | 8 ++- taxonomy/taxonomy.module | 2 - update/update.module | 26 ++++++----- user/user.module | 32 +++++++------- 8 files changed, 139 insertions(+), 98 deletions(-) diff --git includes/common.inc includes/common.inc index e380270..8a6c930 100644 --- includes/common.inc +++ includes/common.inc @@ -1102,7 +1102,7 @@ function fix_gpc_magic() { * @return * The translated string. */ -function t($string, $args = array(), $langcode = NULL) { +function t($string, $args = array(), $context = NULL, $langcode = NULL) { global $language; static $custom_strings; @@ -1123,7 +1123,7 @@ function t($string, $args = array(), $langcode = NULL) { } // Translate with locale module if enabled. elseif (function_exists('locale') && $langcode != 'en') { - $string = locale($string, $langcode); + $string = locale($string, $context, $langcode); } if (empty($args)) { return $string; @@ -1393,28 +1393,28 @@ function format_xml_elements($array) { * @return * A translated string. */ -function format_plural($count, $singular, $plural, $args = array(), $langcode = NULL) { +function format_plural($count, $singular, $plural, $args = array(), $context = NULL, $langcode = NULL) { $args['@count'] = $count; if ($count == 1) { - return t($singular, $args, $langcode); + return t($singular, $args, $context, $langcode); } // Get the plural index through the gettext formula. $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, $langcode) : -1; // Backwards compatibility. if ($index < 0) { - return t($plural, $args, $langcode); + return t($plural, $args, $context, $langcode); } else { switch ($index) { case "0": - return t($singular, $args, $langcode); + return t($singular, $args, $context, $langcode); case "1": - return t($plural, $args, $langcode); + return t($plural, $args, $context, $langcode); default: unset($args['@count']); $args['@count[' . $index . ']'] = $count; - return t(strtr($plural, array('@count' => '@count[' . $index . ']')), $args, $langcode); + return t(strtr($plural, array('@count' => '@count[' . $index . ']')), $args, $context, $langcode); } } } @@ -1458,14 +1458,14 @@ function format_size($size, $langcode = NULL) { else { $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes. $units = array( - t('@size KB', array(), $langcode), - t('@size MB', array(), $langcode), - t('@size GB', array(), $langcode), - t('@size TB', array(), $langcode), - t('@size PB', array(), $langcode), - t('@size EB', array(), $langcode), - t('@size ZB', array(), $langcode), - t('@size YB', array(), $langcode), + t('@size KB', array(), NULL, $langcode), + t('@size MB', array(), NULL, $langcode), + t('@size GB', array(), NULL, $langcode), + t('@size TB', array(), NULL, $langcode), + t('@size PB', array(), NULL, $langcode), + t('@size EB', array(), NULL, $langcode), + t('@size ZB', array(), NULL, $langcode), + t('@size YB', array(), NULL, $langcode), ); foreach ($units as $unit) { if (round($size, 2) >= DRUPAL_KILOBYTE) { @@ -1507,7 +1507,7 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) { break; } } - return $output ? $output : t('0 sec', array(), $langcode); + return $output ? $output : t('0 sec', array(), NULL, $langcode); } /** @@ -1576,13 +1576,13 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL for ($i = 0; $i < $max; $i++) { $c = $format[$i]; if (strpos('AaeDlMT', $c) !== FALSE) { - $date .= t(date_format($date_time, $c), array(), $langcode); + $date .= t(date_format($date_time, $c), array(), NULL, $langcode); } elseif ($c == 'F') { // Special treatment for long month names: May is both an abbreviation // and a full month name in English, but other languages have // different abbreviations. - $date .= trim(t('!long-month-name ' . date_format($date_time, $c), array('!long-month-name' => ''), $langcode)); + $date .= t(date_format($date_time, $c), array(), 'Long month name', $langcode); } elseif (strpos('BcdGgHhIijLmNnOoPSstUuWwYyZz', $c) !== FALSE) { $date .= date_format($date_time, $c); diff --git includes/locale.inc includes/locale.inc index b7d487d..667ee55 100644 --- includes/locale.inc +++ includes/locale.inc @@ -855,31 +855,36 @@ function locale_translate_export_po_form_submit($form, &$form_state) { */ function locale_translate_edit_form(&$form_state, $lid) { // Fetch source string, if possible. - $source = db_fetch_object(db_query('SELECT source, textgroup, location FROM {locales_source} WHERE lid = %d', $lid)); + $source = db_fetch_object(db_query('SELECT source, context, textgroup, location FROM {locales_source} WHERE lid = %d', $lid)); if (!$source) { drupal_set_message(t('String not found.'), 'error'); drupal_goto('admin/build/translate/translate'); } // Add original text to the top and some values for form altering. - $form = array( - 'original' => array( - '#type' => 'item', - '#title' => t('Original text'), - '#markup' => check_plain(wordwrap($source->source, 0)), - ), - 'lid' => array( - '#type' => 'value', - '#value' => $lid - ), - 'textgroup' => array( - '#type' => 'value', - '#value' => $source->textgroup, - ), - 'location' => array( - '#type' => 'value', - '#value' => $source->location - ), + $form['original'] = array( + '#type' => 'item', + '#title' => t('Original text'), + '#markup' => check_plain(wordwrap($source->source, 0)), + ); + if (!empty($source->context)) { + $form['context'] = array( + '#type' => 'item', + '#title' => t('Context'), + '#markup' => check_plain($source->context), + ); + } + $form['lid'] = array( + '#type' => 'value', + '#value' => $lid + ); + $form['textgroup'] = array( + '#type' => 'value', + '#value' => $source->textgroup, + ); + $form['location'] = array( + '#type' => 'value', + '#value' => $source->location ); // Include default form controls with empty values for all languages. @@ -992,7 +997,7 @@ function locale_translate_edit_form_submit($form, &$form_state) { * String deletion confirmation page. */ function locale_translate_delete_page($lid) { - if ($source = db_fetch_object(db_query('SELECT * FROM {locales_source} WHERE lid = %d', $lid))) { + if ($source = db_fetch_object(db_query('SELECT lid, source FROM {locales_source} WHERE lid = %d', $lid))) { return drupal_get_form('locale_translate_delete_form', $source); } else { @@ -1229,8 +1234,26 @@ function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = $current["msgid"] = $quoted; $context = "MSGID"; } + elseif (!strncmp("msgctxt", $line, 7)) { + if ($context == "MSGSTR") { // End current entry, start a new one + _locale_import_one_string($op, $current, $mode, $lang, $file, $group); + $current = array(); + } + elseif (!empty($current["msgctxt"])) { // Already in this context? Parse error + _locale_import_message('The translation file %filename contains an error: "msgctxt" is unexpected on line %line.', $file, $lineno); + return FALSE; + } + $line = trim(substr($line, 5)); + $quoted = _locale_import_parse_quoted($line); + if ($quoted === FALSE) { + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); + return FALSE; + } + $current["msgctxt"] = $quoted; + $context = "MSGCTXT"; + } elseif (!strncmp("msgstr[", $line, 7)) { - if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[] + if (($context != "MSGID") && ($context != "MSGCTXT") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgxtxt, msgid_plural, or msgstr[] _locale_import_message('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', $file, $lineno); return FALSE; } @@ -1250,7 +1273,7 @@ function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = $context = "MSGSTR_ARR"; } elseif (!strncmp("msgstr", $line, 6)) { - if ($context != "MSGID") { // Should come just after a msgid block + if (($context != "MSGID") && ($context != "MSGCTXT")) { // Should come just after a msgid or msgctxt block _locale_import_message('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', $file, $lineno); return FALSE; } @@ -1272,6 +1295,9 @@ function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = if (($context == "MSGID") || ($context == "MSGID_PLURAL")) { $current["msgid"] .= $quoted; } + elseif ($context == "MSGCTXT") { + $current["msgctxt"] .= $quoted; + } elseif ($context == "MSGSTR") { $current["msgstr"] .= $quoted; } @@ -1286,7 +1312,7 @@ function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = } // End of PO file, flush last entry - if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { + if (!empty($current) && !empty($current['msgstr'])) { _locale_import_one_string($op, $current, $mode, $lang, $file, $group); } elseif ($context != "COMMENT") { @@ -1343,7 +1369,7 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL // Store string in memory (only supports single strings) case 'mem-store': - $strings[$value['msgid']] = $value['msgstr']; + $strings[isset($value['msgctxt']) ? $value['msgctxt'] : ''][$value['msgid']] = $value['msgstr']; return; // Called at end of import to inform the user @@ -1384,7 +1410,7 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL if ($key == 0) { $plid = 0; } - $plid = _locale_import_one_string_db($report, $lang, $english[$key], $trans, $group, $comments, $mode, $plid, $key); + $plid = _locale_import_one_string_db($report, $lang, isset($value['msgctxt']) ? $value['msgctxt'] : '', $english[$key], $trans, $group, $comments, $mode, $plid, $key); } } @@ -1392,7 +1418,7 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL // A simple string to import. $english = $value['msgid']; $translation = $value['msgstr']; - _locale_import_one_string_db($report, $lang, $english, $translation, $group, $comments, $mode); + _locale_import_one_string_db($report, $lang, isset($value['msgctxt']) ? $value['msgctxt'] : '', $english, $translation, $group, $comments, $mode); } } } // end of db-store operation @@ -1406,6 +1432,8 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL * array(inserts, updates, deletes). * @param $langcode * Language code to import string into. + * @param $context + * The context of this string. * @param $source * Source string. * @param $translation @@ -1423,8 +1451,9 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL * @return * The string ID of the existing string modified or the new string added. */ -function _locale_import_one_string_db(&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) { - $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup)); +function _locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) { + // The default context is NULL, so we need to cast it to a string for the database layer. + $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND context = '%s' AND textgroup = '%s'", $source, (string) $context, $textgroup)); if (!empty($translation)) { // Skip this string unless it passes a check for dangerous code. @@ -1451,8 +1480,8 @@ function _locale_import_one_string_db(&$report, $langcode, $source, $translation } else { // No such source string in the database yet. - db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', '%s')", $location, $source, $textgroup); - $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup)); + db_query("INSERT INTO {locales_source} (location, source, context, textgroup) VALUES ('%s', '%s', '%s', '%s')", $location, $source, (string) $context, $textgroup); + $lid = db_last_insert_id('locales_source', 'lid'); db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); $report['additions']++; } @@ -1811,7 +1840,7 @@ function _locale_parse_js_file($filepath) { } else { // We don't have the source string yet, thus we insert it into the database. - db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', 'default')", $filepath, $string); + db_query("INSERT INTO {locales_source} (location, source, context, textgroup) VALUES ('%s', '%s', '', 'default')", $filepath, $string); } } } @@ -1835,17 +1864,18 @@ function _locale_parse_js_file($filepath) { */ function _locale_export_get_strings($language = NULL, $group = 'default') { if (isset($language)) { - $result = db_query("SELECT s.lid, s.source, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $language->language, $group); + $result = db_query("SELECT s.lid, s.source, s.context, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $language->language, $group); } else { - $result = db_query("SELECT s.lid, s.source, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $group); + $result = db_query("SELECT s.lid, s.source, s.context, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $group); } $strings = array(); while ($child = db_fetch_object($result)) { $string = array( 'comment' => $child->location, 'source' => $child->source, - 'translation' => isset($child->translation) ? $child->translation : '' + 'context' => $child->context, + 'translation' => isset($child->translation) ? $child->translation : '', ); if ($child->plid) { // Has a parent lid. Since we process in the order of plids, @@ -1922,6 +1952,9 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade $output .= '#: ' . $string['comment'] . "\n"; } $output .= 'msgid ' . _locale_export_string($string['source']); + if (!empty($string['context'])) { + $output .= 'msgctxt ' . _locale_export_string($string['context']); + } if (!empty($string['plural'])) { $plural = $string['plural']; $output .= 'msgid_plural ' . _locale_export_string($strings[$plural]['source']); @@ -2074,7 +2107,7 @@ function _locale_translate_seek() { ); } - $join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid "; + $join = "SELECT s.source, s.location, s.context, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid "; $arguments = array(); $limit_language = FALSE; @@ -2128,19 +2161,21 @@ function _locale_translate_seek() { $result = pager_query($sql, 50, 0, NULL, $arguments); $groups = module_invoke_all('locale', 'groups'); - $header = array(t('Text group'), t('String'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2')); + $header = array(t('Text group'), t('String'), t('Context'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2')); $arr = array(); while ($locale = db_fetch_object($result)) { $arr[$locale->lid]['group'] = $groups[$locale->textgroup]; $arr[$locale->lid]['languages'][$locale->language] = $locale->translation; $arr[$locale->lid]['location'] = $locale->location; $arr[$locale->lid]['source'] = $locale->source; + $arr[$locale->lid]['context'] = $locale->context; } $rows = array(); foreach ($arr as $lid => $value) { $rows[] = array( $value['group'], array('data' => check_plain(truncate_utf8($value['source'], 150, FALSE, TRUE)) . '
' . $value['location'] . ''), + $value['context'], array('data' => _locale_translate_language_list($value['languages'], $limit_language), 'align' => 'center'), array('data' => l(t('edit'), "admin/build/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => 'nowrap'), array('data' => l(t('delete'), "admin/build/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => 'nowrap'), diff --git modules/locale/locale.install modules/locale/locale.install index d71e55e..fcd3d93 100644 --- modules/locale/locale.install +++ modules/locale/locale.install @@ -358,6 +358,12 @@ function locale_schema() { 'not null' => TRUE, 'description' => 'The original string in English.', ), + 'context' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'description' => 'The context this string applies to.', + ), 'version' => array( 'type' => 'varchar', 'length' => 20, @@ -368,7 +374,7 @@ function locale_schema() { ), 'primary key' => array('lid'), 'indexes' => array( - 'source' => array(array('source', 30)), + 'source_context' => array(array('source', 30), 'context'), ), ); diff --git modules/locale/locale.module modules/locale/locale.module index 4fffc96..cd164bc 100644 --- modules/locale/locale.module +++ modules/locale/locale.module @@ -337,7 +337,7 @@ function locale_theme() { * @param $reset * Set to TRUE to reset the in-memory cache. */ -function locale($string = NULL, $langcode = NULL, $reset = FALSE) { +function locale($string = NULL, $context = NULL, $langcode = NULL, $reset = FALSE) { global $language; static $locale_t; @@ -368,9 +368,9 @@ function locale($string = NULL, $langcode = NULL, $reset = FALSE) { // Refresh database stored cache of translations for given language. // We only store short strings used in current version, to improve // performance and consume less memory. - $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION); + $result = db_query("SELECT s.source, s.context, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION); while ($data = db_fetch_object($result)) { - $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation); + $locale_t[$langcode][$data->context][$data->source] = (empty($data->translation) ? TRUE : $data->translation); } cache_set('locale:' . $langcode, $locale_t[$langcode]); } @@ -381,11 +381,11 @@ function locale($string = NULL, $langcode = NULL, $reset = FALSE) { if (!isset($locale_t[$langcode][$string])) { // We do not have this translation cached, so get it from the DB. - $translation = db_fetch_object(db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.source = '%s' AND s.textgroup = 'default'", $langcode, $string)); + $translation = db_fetch_object(db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.source = '%s' AND s.context = '%s' AND s.textgroup = 'default'", $langcode, $string, (string) $context)); if ($translation) { // We have the source string at least. // Cache translation string or TRUE if no translation exists. - $locale_t[$langcode][$string] = (empty($translation->translation) ? TRUE : $translation->translation); + $locale_t[$langcode][$context][$string] = (empty($translation->translation) ? TRUE : $translation->translation); if ($translation->version != VERSION) { // This is the first use of this string under current Drupal version. Save version @@ -397,14 +397,14 @@ function locale($string = NULL, $langcode = NULL, $reset = FALSE) { } else { // We don't have the source string, cache this as untranslated. - db_query("INSERT INTO {locales_source} (location, source, textgroup, version) VALUES ('%s', '%s', 'default', '%s')", request_uri(), $string, VERSION); - $locale_t[$langcode][$string] = TRUE; + db_query("INSERT INTO {locales_source} (location, source, context, textgroup, version) VALUES ('%s', '%s', '%s', 'default', '%s')", request_uri(), $string, (string) $context, VERSION); + $locale_t[$langcode][$context][$string] = TRUE; // Clear locale cache so this string can be added in a later request. cache_clear_all('locale:', 'cache', TRUE); } } - return ($locale_t[$langcode][$string] === TRUE ? $string : $locale_t[$langcode][$string]); + return ($locale_t[$langcode][$context][$string] === TRUE ? $string : $locale_t[$langcode][$context][$string]); } /** diff --git modules/locale/locale.test modules/locale/locale.test index f8e0f9e..3575b2e 100644 --- modules/locale/locale.test +++ modules/locale/locale.test @@ -212,7 +212,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ); $this->drupalPost('admin/settings/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), $langcode); + t($name, array(), NULL, $langcode); // Reset locale cache. locale(NULL, NULL, TRUE); $this->assertText($langcode, t('Language code found.')); @@ -251,7 +251,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save translations')); $this->assertText(t('The string has been saved.'), t('The string has been saved.')); $this->assertEqual($this->getUrl(), url('admin/build/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.')); - $this->assertTrue($name != $translation && t($name, array(), $langcode) == $translation, t('t() works.')); + $this->assertTrue($name != $translation && t($name, array(), NULL, $langcode) == $translation, t('t() works.')); $this->drupalPost('admin/build/translate/translate', $search, t('Filter')); // The indicator should not be here. $this->assertNoRaw($language_indicator, t('String is translated.')); @@ -344,7 +344,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ); $this->drupalPost('admin/settings/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), $langcode); + t($name, array(), NULL, $langcode); // Reset locale cache. $search = array( 'string' => $name, @@ -405,7 +405,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ); $this->drupalPost('admin/settings/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), $langcode); + t($name, array(), NULL, $langcode); // Reset locale cache. locale(NULL, NULL, TRUE); $this->drupalLogout(); diff --git modules/taxonomy/taxonomy.module modules/taxonomy/taxonomy.module index afacc5f..a951c89 100644 --- modules/taxonomy/taxonomy.module +++ modules/taxonomy/taxonomy.module @@ -286,7 +286,7 @@ function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) { $hierarchy = 2; break; } - elseif (count($term->parents) == 1 && 0 !== array_shift($term->parents)) { + elseif (count($term->parents) == 1 && current($term->parents) != 0) { $hierarchy = 1; } } diff --git modules/update/update.module modules/update/update.module index 69754f1..f66999e 100644 --- modules/update/update.module +++ modules/update/update.module @@ -415,11 +415,11 @@ function update_refresh() { function update_mail($key, &$message, $params) { $language = $message['language']; $langcode = $language->language; - $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), $langcode); + $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), NULL, $langcode); foreach ($params as $msg_type => $msg_reason) { $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $language); } - $message['body'][] = t('See the available updates page for more information:', array(), $langcode) . "\n" . url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language)); + $message['body'][] = t('See the available updates page for more information:', array(), NULL, $langcode) . "\n" . url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language)); } /** @@ -448,53 +448,53 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan switch ($msg_reason) { case UPDATE_NOT_SECURE: if ($msg_type == 'core') { - $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), $langcode); + $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), NULL, $langcode); } else { - $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), $langcode); + $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), NULL, $langcode); } break; case UPDATE_REVOKED: if ($msg_type == 'core') { - $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), $langcode); + $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), NULL, $langcode); } else { - $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), $langcode); + $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), NULL, $langcode); } break; case UPDATE_NOT_SUPPORTED: if ($msg_type == 'core') { - $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), $langcode); + $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), NULL, $langcode); } else { - $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended! Please see the project homepage for more details.', array(), $langcode); + $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended! Please see the project homepage for more details.', array(), NULL, $langcode); } break; case UPDATE_NOT_CURRENT: if ($msg_type == 'core') { - $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode); + $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), NULL, $langcode); } else { - $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode); + $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), NULL, $langcode); } break; case UPDATE_UNKNOWN: case UPDATE_NOT_CHECKED: if ($msg_type == 'core') { - $text = t('There was a problem determining the status of available updates for your version of Drupal.', array(), $langcode); + $text = t('There was a problem determining the status of available updates for your version of Drupal.', array(), NULL, $langcode); } else { - $text = t('There was a problem determining the status of available updates for one or more of your modules or themes.', array(), $langcode); + $text = t('There was a problem determining the status of available updates for one or more of your modules or themes.', array(), NULL, $langcode); } break; } if ($report_link) { - $text .= ' ' . t('See the available updates page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), $langcode); + $text .= ' ' . t('See the available updates page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), NULL, $langcode); } return $text; diff --git modules/user/user.module modules/user/user.module index 23f208f..821771c 100644 --- modules/user/user.module +++ modules/user/user.module @@ -1935,35 +1935,35 @@ function _user_mail_text($key, $language = NULL, $variables = array()) { // No override, return default string. switch ($key) { case 'register_no_approval_required_subject': - return t('Account details for !username at !site', $variables, $langcode); + return t('Account details for !username at !site', $variables, NULL, $langcode); case 'register_no_approval_required_body': - return t("!username,\n\nThank you for registering at !site. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $variables, $langcode); + return t("!username,\n\nThank you for registering at !site. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $variables, NULL, $langcode); case 'register_admin_created_subject': - return t('An administrator created an account for you at !site', $variables, $langcode); + return t('An administrator created an account for you at !site', $variables, NULL, $langcode); case 'register_admin_created_body': - return t("!username,\n\nA site administrator at !site has created an account for you. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $variables, $langcode); + return t("!username,\n\nA site administrator at !site has created an account for you. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $variables, NULL, $langcode); case 'register_pending_approval_subject': case 'register_pending_approval_admin_subject': - return t('Account details for !username at !site (pending admin approval)', $variables, $langcode); + return t('Account details for !username at !site (pending admin approval)', $variables, NULL, $langcode); case 'register_pending_approval_body': - return t("!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.\n\n\n-- !site team", $variables, $langcode); + return t("!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.\n\n\n-- !site team", $variables, NULL, $langcode); case 'register_pending_approval_admin_body': - return t("!username has applied for an account.\n\n!edit_uri", $variables, $langcode); + return t("!username has applied for an account.\n\n!edit_uri", $variables, NULL, $langcode); case 'password_reset_subject': - return t('Replacement login information for !username at !site', $variables, $langcode); + return t('Replacement login information for !username at !site', $variables, NULL, $langcode); case 'password_reset_body': - return t("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $variables, $langcode); + return t("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $variables, NULL, $langcode); case 'status_activated_subject': return t('Account details for !username at !site (approved)', $variables, $langcode); case 'status_activated_body': - return t("!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n", $variables, $langcode); + return t("!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n", $variables, NULL, $langcode); case 'status_blocked_subject': - return t('Account details for !username at !site (blocked)', $variables, $langcode); + return t('Account details for !username at !site (blocked)', $variables, NULL, $langcode); case 'status_blocked_body': - return t("!username,\n\nYour account on !site has been blocked.", $variables, $langcode); + return t("!username,\n\nYour account on !site has been blocked.", $variables, NULL, $langcode); case 'cancel_confirm_subject': - return t('Account cancellation request for !username at !site', $variables, $langcode); + return t('Account cancellation request for !username at !site', $variables, NULL, $langcode); case 'cancel_confirm_body': return t("!username, @@ -1975,14 +1975,14 @@ You may now cancel your account on !uri_brief by clicking this link or copying a NOTE: The cancellation of your account is not reversible. -This link expires in one day and nothing will happen if it is not used.", $variables, $langcode); +This link expires in one day and nothing will happen if it is not used.", $variables, NULL, $langcode); case 'status_canceled_subject': - return t('Account details for !username at !site (canceled)', $variables, $langcode); + return t('Account details for !username at !site (canceled)', $variables, NULL, $langcode); case 'status_canceled_body': return t("!username, -Your account on !site has been canceled.", $variables, $langcode); +Your account on !site has been canceled.", $variables, NULL, $langcode); } } }