--- relevant_content.module	2008-11-06 20:37:48.000000000 +0700
+++ relevant_content.module.patched	2009-08-27 07:49:49.000000000 +0700
@@ -353,7 +353,18 @@ function relevant_content_block($op = 'l
         $exclude[] = arg(1);
       }
 
-      if ($nodes = relevant_content_get_nodes($settings[$delta]['types'], $terms, $exclude, $settings[$delta]['limit'])) {
+      //Create a node language list. This will restrict relevant nodes to node's language and language neutral only.
+      //Empty string (''), means Language Neutral, will include language neutral relevant nodes
+      $language = array();
+      if (arg(0) == 'node' && is_numeric(arg(1))) {
+        $node_obj = node_load(arg(1));
+        $language[] = ''; // language neutral
+        if ($node_obj->language) {
+          $language[] = $node_obj->language; // node's language
+        }
+      }
+
+      if ($nodes = relevant_content_get_nodes($settings[$delta]['types'], $terms, $exclude, $language, $settings[$delta]['limit'])) {
         $header = isset($settings[$delta]['header_text']) ? $settings[$delta]['header_text'] : FALSE;
         return array(
           'subject' => t('Relevant Content'),
@@ -452,12 +463,15 @@ function theme_relevant_content_block($n
  *   Array of Term ID's
  * @param $exclude
  *   Array - Optional: An array of Node ID's to exclude. Useful for excluding the node you might be comparing to currently. Default: No exclusions.
+ * @param $language
+ *   Array - Optional: An array of languages to restrict nodes to these language(s) only. If an empty string exists in array, then Language Neutral
+ *                     relevant nodes will be included. Empty array will include all languages relevant nodes.
  * @param $limit
  *   Integer - Optional: Integer controlling the maximum number of nodes returned. Default: 5
  * @return mixed
  *   FALSE if no result or error or an associative array with node ID's as keys and the value's as arrays of nid's, vid's, title's, type's & term match counts.
  */
-function relevant_content_get_nodes($types, $terms, $exclude = array(), $limit = 5) {
+function relevant_content_get_nodes($types, $terms, $exclude = array(), $language = array(), $limit = 5) {
   // If terms or types are empty, there isn't anything to match to so not a lot of point continuing.
   if (empty($terms) || empty($types)) return FALSE;
 
@@ -482,6 +496,13 @@ function relevant_content_get_nodes($typ
     $values = array_merge($values, array_values($exclude));
   }
 
+  // Define the SQL for Language Restriction
+  $language_sql = '';
+  if (!empty($language)) {
+    $language_sql = 'AND n.language IN ('. db_placeholders($language, 'varchar') .')';
+    $values = array_merge($values, array_values($language));
+  }
+
 
   // Add the result limit to the values array
   $values = array_merge($values, array($limit));
@@ -497,7 +518,7 @@ SELECT
   COUNT(*) AS cnt
 FROM {node} n
 LEFT JOIN {term_node} tn ON tn.nid = n.nid AND {$term_sql}
-WHERE {$types_sql} AND n.status = 1 AND tn.tid IS NOT NULL {$exclude_sql}
+WHERE {$types_sql} AND n.status = 1 AND tn.tid IS NOT NULL {$exclude_sql} {$language_sql}
 GROUP BY n.nid
 ORDER BY cnt DESC, n.created DESC, n.nid DESC
 LIMIT %d
