Comment count for different language I have a blog section on a bilingual page that I'm working on and I'd like to show the total number of comments below each teaser. Not to confuse users, the total should be total number of comments for the language that user is in. So, let's say if I have Spanish and English version of the website. If the user is on English, it should only show total number of comments in English not the grand total. Likewise, if the user is on Spanish, it should only show total number of comments in Spanish. Right now, it shows grand total and confuses users. How do I resolve this issue? Any help would be appreciated.  

Drupal 7.x
This is untested but you could override the comment_count variable in a template_preprocess_node.

/**
 * Implements template_preprocess_node().
 */
function MYTHEME_preprocess_node(&amp;$variables) {
  // Not sure if you wanted to limit to teasers but here goes.
  if ($variables['view_mode'] == 'teaser') {
    // Get the node object.
    $node = $variables['elements']['#node'];
    // Fetch the language the user is browsing the site in.
    global $language;

    // Query against the database all comments for the node in language the user
    // is browsing the site in.    
    $result = db_select('comment', 'c')
      -&gt;fields('c', array('cid', 'language', 'nid'))
      -&gt;condition('language', $language-&gt;language, '=')
      -&gt;condition('nid', $node-&gt;nid, '=')
      -&gt;execute();
    $comment_count = $result-&gt;rowCount();

    // Now we override the comment count from the comment module with our result.
    $variables['comment_count'] = $comment_count;
  }
}


Observe that Views for example fetches $node->comment_count which is set in a node_load by the comment module.

So if you are using Views to display the comment count will still be wrong. One idea could be to add your own hook_node_load and populate $node->comment_count. This needs to be done after the comment module has run it's hook_node_load.

But if you are displaying nodes using the teaser view mode the code above (maybe with some modifications) should work :)

Edit
On second hand it might make more sense to setup a new variable called something like comment_count_active_language instead of overriding comment_count. In theory the comment_count is correct for the node. You are more asking for another count.

Change the example above but setup a new variable.

$variables['comment_count_active_language'] = $comment_count;


Then print that in node.tpl.php instead of $comment_count.