Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.789
diff -u -p -r1.789 comment.module
--- modules/comment/comment.module	16 Oct 2009 03:40:40 -0000	1.789
+++ modules/comment/comment.module	16 Oct 2009 05:20:46 -0000
@@ -705,6 +705,15 @@ function comment_get_thread($node, $mode
     ->condition('c.nid', $node->nid)
     ->addTag('node_access');
 
+  // Pass all comment filters allowed for this node type.
+  $comment_filters = variable_get('comment_filters_' . $node->type, array());
+  if (!empty($comment_filters)) {
+    $query->addTag('comment_filter');
+    $query->addMetaData('comment_filters', $comment_filters);
+    $count_query->addTag('comment_filter');
+    $count_query->addMetaData('comment_filters', $comment_filters);
+  }
+
   if (!user_access('administer comments')) {
     $query->condition('c.status', COMMENT_PUBLISHED);
     $count_query->condition('c.status', COMMENT_PUBLISHED);
@@ -1014,6 +1023,16 @@ function comment_form_node_type_form_alt
       '#title' => t('Require preview'),
       '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, COMMENT_PREVIEW_OPTIONAL),
     );
+    // Collect all modules that define comment filters.
+    $filters = module_implements('query_comment_filter_alter');
+    $filters = array_intersect(module_list(), $filters);
+    $form['comment']['comment_filters'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Comment filters'),
+      '#options' => $filters,
+      '#default_value' => variable_get('comment_filters_' . $form['#node_type']->type, array()),
+      '#access' => (count($filters) > 0),
+    );
   }
 }
 
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.264
diff -u -p -r1.264 locale.module
--- modules/locale/locale.module	16 Oct 2009 02:04:42 -0000	1.264
+++ modules/locale/locale.module	16 Oct 2009 05:20:47 -0000
@@ -468,7 +468,7 @@ function locale_theme() {
  */
 function locale_field_attach_view_alter(&$output, $context) {
   // In locale_field_fallback_view() we might call field_attach_view(). The
-  // static variable avoids unnecessary recursion. 
+  // static variable avoids unnecessary recursion.
   static $recursion;
 
   // Do not apply fallback rules if disabled or if Locale is not registered as a
@@ -1067,3 +1067,15 @@ function locale_date_format_reset_form_s
   $form_state['redirect'] = 'admin/config/regional/date-time/locale';
 }
 
+/**
+ * Implement hook_query_TAG_alter().
+ *
+ * Adds a filter by language for comments.
+ */
+function locale_query_comment_filter_alter(QueryAlterableInterface $query) {
+  global $language;
+  $filters = $query->getMetaData('comment_filters');
+  if (in_array('locale', $filters)) {
+    $query->where("language = :name", array(':name' => $language->language));
+  }
+}
