--- taxonomy.module.orig	2007-03-26 20:43:07.698055400 +0200
+++ taxonomy.module	2007-04-01 02:41:34.705979800 +0200
@@ -181,6 +181,10 @@ function taxonomy_overview_terms($vid) {
   if (!$vocabulary) {
     return drupal_not_found();
   }
+  // Localizer support
+  if (function_exists('tobject')) {
+    $vocabulary = tobject('taxonomy_vocabulary', $vocabulary->vid, $vocabulary);
+  }
 
   drupal_set_title(check_plain($vocabulary->name));
   $start_from      = $_GET['page'] ? $_GET['page'] : 0;
@@ -190,6 +194,10 @@ function taxonomy_overview_terms($vid) {
 
   $tree = taxonomy_get_tree($vocabulary->vid);
   foreach ($tree as $term) {
+    // Localizer support
+    if (function_exists('tobject')) {
+      $term = tobject('taxonomy_term', $term->tid, $term);
+    }
     $total_entries++; // we're counting all-totals, not displayed
     if (($start_from && ($start_from * $page_increment) >= $total_entries) || ($displayed_count == $page_increment)) {
       continue;
@@ -599,6 +607,10 @@ function taxonomy_term_confirm_delete_su
  */
 function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
   $vocabulary = taxonomy_get_vocabulary($vid);
+  // Localizer support
+  if (function_exists('tobject')) {
+    $vocabulary = tobject('taxonomy_vocabulary', $vocabulary->vid, $vocabulary);
+  }
   $help = ($help) ? $help : $vocabulary->help;
   if ($vocabulary->required) {
     $blank = 0;
@@ -646,6 +658,10 @@ function taxonomy_get_vocabularies($type
   $vocabularies = array();
   $node_types = array();
   while ($voc = db_fetch_object($result)) {
+    // Localizer support
+    if (function_exists('tobject')) {
+      $voc = tobject('taxonomy_vocabulary', $voc->vid, $voc);
+    }
     $node_types[$voc->vid][] = $voc->type;
     unset($voc->type);
     $voc->nodes = $node_types[$voc->vid];
@@ -745,6 +761,10 @@ function taxonomy_node_get_terms_by_voca
   $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight', 't', 'tid'), $vid, $nid);
   $terms = array();
   while ($term = db_fetch_object($result)) {
+    // Localizer support
+    if (function_exists('tobject')) {
+      $term = tobject('taxonomy_term', $term->tid, $term);
+    }
     $terms[$term->$key] = $term;
   }
   return $terms;
@@ -760,6 +780,10 @@ function taxonomy_node_get_terms($nid, $
     $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid);
     $terms[$nid] = array();
     while ($term = db_fetch_object($result)) {
+      // Localizer support
+      if (function_exists('tobject')) {
+        $term=tobject('taxonomy_term', $term->tid, $term);
+      }
       $terms[$nid][$term->$key] = $term;
     }
   }
@@ -884,6 +908,10 @@ function taxonomy_get_related($tid, $key
     $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
     $related = array();
     while ($term = db_fetch_object($result)) {
+      // Localizer support
+      if (function_exists('tobject')) {
+        $term = tobject('taxonomy_term', $term->tid, $term);
+      }
       $related[$term->$key] = $term;
     }
     return $related;
@@ -901,6 +929,10 @@ function taxonomy_get_parents($tid, $key
     $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid);
     $parents = array();
     while ($parent = db_fetch_object($result)) {
+      // Localizer support
+      if (function_exists('tobject')) {
+        $parent=tobject('taxonomy_term', $parent->tid, $parent);
+      }
       $parents[$parent->$key] = $parent;
     }
     return $parents;
@@ -938,6 +970,10 @@ function taxonomy_get_children($tid, $vi
   }
   $children = array();
   while ($term = db_fetch_object($result)) {
+    // Localizer support
+    if (function_exists('tobject')) {
+      $term = tobject('taxonomy_term', $term->tid, $term);
+    }
     $children[$term->$key] = $term;
   }
   return $children;
@@ -976,6 +1012,10 @@ function taxonomy_get_tree($vid, $parent
 
     $result = db_query(db_rewrite_sql('SELECT t.tid, t.*, parent FROM {term_data} t INNER JOIN  {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $vid);
     while ($term = db_fetch_object($result)) {
+      // Localizer support
+      if (function_exists('tobject')) {
+        $term = tobject('taxonomy_term', $term->tid, $term);
+      }
       $children[$vid][$term->parent][] = $term->tid;
       $parents[$vid][$term->tid][] = $term->parent;
       $terms[$vid][$term->tid] = $term;
@@ -1099,9 +1139,15 @@ function _taxonomy_term_children($tid) {
  *   An array of matching term objects.
  */
 function taxonomy_get_term_by_name($name) {
-  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER('%s') LIKE LOWER(t.name)", 't', 'tid'), trim($name));
+  // Fix for localizer 31/03/2007 smk
+  // $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER('%s') LIKE LOWER(t.name)", 't', 'tid'), trim($name));
+  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t LEFT JOIN {localizertranslation} l ON l.object_key = t.tid AND l.object_name = 'taxonomy_term' AND object_field = 'name' AND l.locale IN (". localizer_get_contentlocales_assql() .") WHERE LOWER('%s') LIKE LOWER(t.name) OR LOWER('%s') LIKE LOWER(l.translation)", 't', 'tid'), trim($name), trim($name));
   $result = array();
   while ($term = db_fetch_object($db_result)) {
+    // Localizer support
+    if (function_exists('tobject')) {
+      $term = tobject('taxonomy_term', $term->tid,$term);
+    }
     $result[] = $term;
   }
 
@@ -1125,6 +1171,10 @@ function taxonomy_get_vocabulary($vid) {
     $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
     $node_types = array();
     while ($voc = db_fetch_object($result)) {
+      // Localizer support
+      if(function_exists('tobject')) {
+        $voc = tobject('taxonomy_vocabulary', $voc->vid, $voc);
+      }
       $node_types[] = $voc->type;
       unset($voc->type);
       $voc->nodes = $node_types;
@@ -1350,6 +1400,10 @@ function taxonomy_term_page($str_tids = 
     $tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
     $names = array();
     while ($term = db_fetch_object($result)) {
+      // Localizer support
+      if (function_exists('tobject')) {
+        $term = tobject('taxonomy_term', $term->tid, $term);
+      }
       $tids[] = $term->tid;
       $names[] = $term->name;
     }
@@ -1472,12 +1526,18 @@ function taxonomy_autocomplete($vid, $st
   // Fetch last tag
   $last_string = trim(array_pop($array));
   if ($last_string != '') {
-    $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = %d AND LOWER(t.name) LIKE LOWER('%%%s%%')", 't', 'tid'), $vid, $last_string, 0, 10);
+    // Fix for localizer 31/03/2007 smk
+    // $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = %d AND LOWER(t.name) LIKE LOWER('%%%s%%')", 't', 'tid'), $vid, $last_string, 0, 10);
+    $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t LEFT JOIN {localizertranslation} l ON l.object_key = t.tid AND l.object_name = 'taxonomy_term' AND object_field = 'name' AND l.locale IN (". localizer_get_contentlocales_assql() .") WHERE t.vid = %d AND (LOWER(t.name) LIKE LOWER('%%%s%%') OR LOWER(l.translation) LIKE LOWER('%%%s%%'))", 't', 'tid'), $vid, $last_string, $last_string, 0, 10);
 
     $prefix = count($array) ? implode(', ', $array) .', ' : '';
 
     $matches = array();
     while ($tag = db_fetch_object($result)) {
+      // Localizer support
+      if (function_exists('tobject')) {
+        $tag = tobject('taxonomy_term', $tag->tid, $tag);
+      }
       $n = $tag->name;
       // Commas and quotes in terms are special cases, so encode 'em.
       if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
