0

i have problem with drupal. I'm using the watchdog function to save some log messages, but when i go to read them in the admin panel (admin/reports/dblog) they get detected by the T function and so i have a lot of unnecessary log entries inside the translate content page. Is there a way to disable the detection for that page? Thanks

0

Yes. The watchdog report page is driven by dblog_overview() which utilizes the theme function theme_dblog_message() to render the message columns.

If you override the function, you can alter the arguments for t() so that $options = array('langcode' => 'en') which will make t() ignore it for translation.

For example, if you defined a mytheme_dblog_message() within your theme's template.php:

function mytheme_dblog_message($variables) {
  $output = '';
  $event = $variables['event'];
  // Check for required properties.
  if (isset($event->message) && isset($event->variables)) {
    // Messages without variables or user specified text.
    if ($event->variables === 'N;') {
      $output = $event->message;
    }
    // Message to translate with injected variables.
    else {
      // Add langcode = 'en' to prevent translation
      $output = t($event->message, unserialize($event->variables), array('langcode' => 'en'));

    }
    if ($variables['link'] && isset($event->wid)) {
      // Truncate message to 56 chars.
      $output = truncate_utf8(filter_xss($output, array()), 56, TRUE, TRUE);
      $output = l($output, 'admin/reports/event/' . $event->wid, array('html' => TRUE));
    }
  }
  return $output;
}
1

I made it like this:

function MYADMINTHEME_dblog_message($variables) {
  $output = '';
  $event = $variables['event'];
  // Check for required properties.
  if (isset($event->message) && isset($event->variables)) {
    // Messages without variables or user specified text.
    if ($event->variables === 'N;') {
      $output = $event->message;
    }
    // Message to translate with injected variables.
    else {
      $output = format_string($event->message, unserialize($event->variables));
    }
    if ($variables['link'] && isset($event->wid)) {
      // Truncate message to 56 chars.
      $output = truncate_utf8(filter_xss($output, array()), 56, TRUE, TRUE);
      $output = l($output, 'admin/reports/event/' . $event->wid, array('html' => TRUE));
    }
  }
  return $output;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.