summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-04-24 13:53:15 +0000
committerDries Buytaert <dries@buytaert.net>2007-04-24 13:53:15 +0000
commitf73610bec64dbc81b8e5031ac6778c5f539cb730 (patch)
tree473284ff160a3ea8818c90d84043cac13bf336af /includes
parentffe4dc84d449e601561b7128212daf9758b6d9b0 (diff)
downloadbrdo-f73610bec64dbc81b8e5031ac6778c5f539cb730.tar.gz
brdo-f73610bec64dbc81b8e5031ac6778c5f539cb730.tar.bz2
- Patch #76588 by Gabor: made log messages translatable. Yay.
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc11
-rw-r--r--includes/common.inc16
-rw-r--r--includes/file.inc12
-rw-r--r--includes/form.inc4
-rw-r--r--includes/image.inc2
-rw-r--r--includes/locale.inc14
-rw-r--r--includes/unicode.inc4
7 files changed, 35 insertions, 28 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index c93f2a81c..649d1bf81 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -646,19 +646,26 @@ function request_uri() {
* @param $type
* The category to which this message belongs.
* @param $message
- * The message to store in the log.
+ * The message to store in the log. See t() for documentation
+ * on how $message and $variables interact. Keep $message
+ * translateable by not concatenating dynamic values into it!
+ * @param $variables
+ * Array of variables to replace in the message on display or
+ * NULL if message is already translated or not possible to
+ * translate.
* @param $severity
* The severity of the message, as per RFC 3164
* @param $link
* A link to associate with the message.
*/
-function watchdog($type, $message, $severity = WATCHDOG_NOTICE, $link = NULL) {
+function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
global $user, $base_root;
// Prepare the fields to be logged
$log_message = array(
'type' => $type,
'message' => $message,
+ 'variables' => $variables,
'severity' => $severity,
'link' => $link,
'user' => $user,
diff --git a/includes/common.inc b/includes/common.inc
index 1da216095..d59e864a9 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -332,7 +332,7 @@ function drupal_site_offline() {
function drupal_not_found() {
drupal_set_header('HTTP/1.1 404 Not Found');
- watchdog('page not found', check_plain($_GET['q']), WATCHDOG_WARNING);
+ watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
// Keep old path for reference
if (!isset($_REQUEST['destination'])) {
@@ -362,7 +362,7 @@ function drupal_not_found() {
*/
function drupal_access_denied() {
drupal_set_header('HTTP/1.1 403 Forbidden');
- watchdog('access denied', check_plain($_GET['q']), WATCHDOG_WARNING);
+ watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
// Keep old path for reference
if (!isset($_REQUEST['destination'])) {
@@ -556,7 +556,7 @@ function drupal_error_handler($errno, $message, $filename, $line) {
drupal_set_message($entry, 'error');
}
- watchdog('php', t('%message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line)), WATCHDOG_ERROR);
+ watchdog('php', '%message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line), WATCHDOG_ERROR);
}
}
@@ -653,7 +653,7 @@ function fix_gpc_magic() {
* - %variable, which indicates that the string should be highlighted with
* theme_placeholder() which shows up by default as <em>emphasized</em>.
* @code
- * watchdog('mail', t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name)));
+ * $message = t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name));
* @endcode
*
* When using t(), try to put entire sentences and strings in one t() call.
@@ -2041,14 +2041,14 @@ function drupal_cron_run() {
if (time() - $semaphore > 3600) {
// Either cron has been running for more than an hour or the semaphore
// was not reset due to a database error.
- watchdog('cron', t('Cron has been running for more than an hour and is most likely stuck.'), WATCHDOG_ERROR);
+ watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR);
// Release cron semaphore
variable_del('cron_semaphore');
}
else {
// Cron is still running normally.
- watchdog('cron', t('Attempting to re-run cron while it is already running.'), WATCHDOG_WARNING);
+ watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
}
}
else {
@@ -2063,7 +2063,7 @@ function drupal_cron_run() {
// Record cron time
variable_set('cron_last', time());
- watchdog('cron', t('Cron run completed.'), WATCHDOG_NOTICE);
+ watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
// Release cron semaphore
variable_del('cron_semaphore');
@@ -2079,7 +2079,7 @@ function drupal_cron_run() {
function drupal_cron_cleanup() {
// See if the semaphore is still locked.
if (variable_get('cron_semaphore', FALSE)) {
- watchdog('cron', t('Cron run exceeded the time limit and was aborted.'), WATCHDOG_WARNING);
+ watchdog('cron', 'Cron run exceeded the time limit and was aborted.', array(), WATCHDOG_WARNING);
// Release cron semaphore
variable_del('cron_semaphore');
diff --git a/includes/file.inc b/includes/file.inc
index 7e70ed882..1673b75da 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -107,7 +107,7 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
}
else {
form_set_error($form_item, t('The directory %directory is not writable', array('%directory' => $directory)));
- watchdog('file system', t('The directory %directory is not writable, because it does not have the correct permissions set.', array('%directory' => $directory)), WATCHDOG_ERROR);
+ watchdog('file system', 'The directory %directory is not writable, because it does not have the correct permissions set.', array('%directory' => $directory), WATCHDOG_ERROR);
return FALSE;
}
}
@@ -119,9 +119,9 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
chmod($directory .'/.htaccess', 0664);
}
else {
- $message = t("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", array('%directory' => $directory, '!htaccess' => '<br />'. nl2br(check_plain($htaccess_lines))));
- form_set_error($form_item, $message);
- watchdog('security', $message, WATCHDOG_ERROR);
+ $variables = array('%directory' => $directory, '!htaccess' => '<br />'. nl2br(check_plain($htaccess_lines)));
+ form_set_error($form_item, t("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables));
+ watchdog('security', "Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables, WATCHDOG_ERROR);
}
}
@@ -239,7 +239,7 @@ function file_check_upload($source = 'upload') {
// This overcomes open_basedir restrictions for future file operations.
if (!move_uploaded_file($_FILES["files"]["tmp_name"][$source], $file->filepath)) {
drupal_set_message(t('File upload error. Could not move uploaded file.'));
- watchdog('file', t('Upload Error. Could not move uploaded file (%file) to destination (%destination).', array('%file' => $_FILES["files"]["tmp_name"][$source], '%destination' => $file->filepath)));
+ watchdog('file', 'Upload Error. Could not move uploaded file (%file) to destination (%destination).', array('%file' => $_FILES["files"]["tmp_name"][$source], '%destination' => $file->filepath));
return FALSE;
}
@@ -320,7 +320,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
if ($basename === FALSE) {
$source = is_object($source) ? $source->filepath : $source;
drupal_set_message(t('The selected file %file could not be uploaded, because the destination %directory is not properly configured.', array('%file' => $source, '%directory' => $dest)), 'error');
- watchdog('file system', t('The selected file %file could not be uploaded, because the destination %directory could not be found, or because its permissions do not allow the file to be written.', array('%file' => $source, '%directory' => $dest)), WATCHDOG_ERROR);
+ watchdog('file system', 'The selected file %file could not be uploaded, because the destination %directory could not be found, or because its permissions do not allow the file to be written.', array('%file' => $source, '%directory' => $dest), WATCHDOG_ERROR);
return 0;
}
diff --git a/includes/form.inc b/includes/form.inc
index 8a5413272..dc843d286 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -553,13 +553,13 @@ function _form_validate($elements, $form_id = NULL) {
foreach ($value as $v) {
if (!isset($options[$v])) {
form_error($elements, t('An illegal choice has been detected. Please contact the site administrator.'));
- watchdog('form', t('Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'])), WATCHDOG_ERROR);
+ watchdog('form', 'Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
}
}
}
elseif (!isset($options[$elements['#value']])) {
form_error($elements, t('An illegal choice has been detected. Please contact the site administrator.'));
- watchdog('form', t('Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'])), WATCHDOG_ERROR);
+ watchdog('form', 'Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
}
}
}
diff --git a/includes/image.inc b/includes/image.inc
index 01db0c5e1..6f20c082d 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -58,7 +58,7 @@ function image_toolkit_invoke($method, $params = array()) {
return call_user_func_array($function, $params);
}
else {
- watchdog('php', t("The selected image handling toolkit %toolkit can not correctly process %function.", array('%toolkit' => $toolkit, '%function' => $function)), WATCHDOG_ERROR);
+ watchdog('php', 'The selected image handling toolkit %toolkit can not correctly process %function.', array('%toolkit' => $toolkit, '%function' => $function), WATCHDOG_ERROR);
return FALSE;
}
}
diff --git a/includes/locale.inc b/includes/locale.inc
index e9f60f627..fd9cbdcaa 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -50,7 +50,7 @@ function _locale_add_language($code, $name, $native, $direction = 0, $domain = '
drupal_set_message(t('The language %language has been created.', array('%language' => t($name))));
}
- watchdog('locale', t('The %language language (%code) has been created.', array('%language' => t($name), '%code' => $code)));
+ watchdog('locale', 'The %language language (%code) has been created.', array('%language' => $name, '%code' => $code));
}
/**
@@ -457,9 +457,9 @@ function _locale_admin_import_submit($form_id, $form_values) {
// Now import strings into the language
if ($ret = _locale_import_po($file, $form_values['langcode'], $form_values['mode']) == FALSE) {
- $message = t('The translation import of %filename failed.', array('%filename' => $file->filename));
- drupal_set_message($message, 'error');
- watchdog('locale', $message, WATCHDOG_ERROR);
+ $variables = array('%filename' => $file->filename);
+ drupal_set_message(t('The translation import of %filename failed.', $variables), 'error');
+ watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR);
}
}
else {
@@ -704,7 +704,7 @@ function _locale_import_po($file, $lang, $mode) {
menu_rebuild();
drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings and %update strings were updated.', array('%number' => $additions, '%update' => $updates)));
- watchdog('locale', t('Imported %file into %locale: %number new strings added and %update updated.', array('%file' => $file->filename, '%locale' => $lang, '%number' => $additions, '%update' => $updates)));
+ watchdog('locale', 'Imported %file into %locale: %number new strings added and %update updated.', array('%file' => $file->filename, '%locale' => $lang, '%number' => $additions, '%update' => $updates));
return TRUE;
}
@@ -1353,7 +1353,7 @@ function _locale_export_po($language = NULL) {
$header .= "\"Plural-Forms: nplurals=". $meta->plurals ."; plural=". strtr($meta->formula, array('$' => '')) .";\\n\"\n";
}
$header .= "\n";
- watchdog('locale', t('Exported %locale translation file: %filename.', array('%locale' => $meta->name, '%filename' => $filename)));
+ watchdog('locale', 'Exported %locale translation file: %filename.', array('%locale' => $meta->name, '%filename' => $filename));
}
// Generating Portable Object Template
@@ -1374,7 +1374,7 @@ function _locale_export_po($language = NULL) {
$header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
$header .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n";
$header .= "\n";
- watchdog('locale', t('Exported translation file: %filename.', array('%filename' => $filename)));
+ watchdog('locale', 'Exported translation file: %filename.', array('%filename' => $filename));
}
// Start download process
diff --git a/includes/unicode.inc b/includes/unicode.inc
index 7f546d4f9..93ec81772 100644
--- a/includes/unicode.inc
+++ b/includes/unicode.inc
@@ -148,7 +148,7 @@ function drupal_xml_parser_create(&$data) {
$data = ereg_replace('^(<\?xml[^>]+encoding)="([^"]+)"', '\\1="utf-8"', $out);
}
else {
- watchdog('php', t("Could not convert XML encoding %s to UTF-8.", array('%s' => $encoding)), WATCHDOG_WARNING);
+ watchdog('php', 'Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding), WATCHDOG_WARNING);
return 0;
}
}
@@ -181,7 +181,7 @@ function drupal_convert_to_utf8($data, $encoding) {
$out = @recode_string($encoding .'..utf-8', $data);
}
else {
- watchdog('php', t("Unsupported encoding %s. Please install iconv, GNU recode or mbstring for PHP.", array('%s' => $encoding)), WATCHDOG_ERROR);
+ watchdog('php', 'Unsupported encoding %s. Please install iconv, GNU recode or mbstring for PHP.', array('%s' => $encoding), WATCHDOG_ERROR);
return FALSE;
}