Index: i18n.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n.module,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 i18n.module
--- i18n.module	8 Dec 2004 17:19:00 -0000	1.9.2.1
+++ i18n.module	21 Jan 2005 16:50:19 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: i18n.module,v 1.9.2.1 2004/12/08 17:19:00 jareyero Exp $
+// $Id: i18n.module,v 1.1.2.1 2004/12/24 11:11:49 ber Exp $
 
 /**
  * Internationalization (i18n) module
@@ -34,7 +34,8 @@
       if ($path == $i18n_langpath) {
          // When path is only language code
         $_GET['q'] =  variable_get('i18n_frontpage',0) ? i18n_frontpage() : variable_get('site_frontpage','node'); 
-      }else{ 
+      }
+      else { 
         //search alias with and without lang and remove lang
         $_GET['q'] = i18n_get_normal_path($path);
       }
@@ -409,11 +410,25 @@
   if (!$url) {
     $url = i18n_get_original_path();
   }
-    // If url has lang_prefix, remove it
+  
+  // If url has lang_prefix, remove it
   if (i18n_get_lang_prefix($url)) {
     $url = substr($url, 3);
   }
- // $result= l($text, $url, $attributes, $query);
+  
+  //are we looking at a node?
+  if (preg_match("/^(node\/)([0-9]*)$/",$url,$matches)) {
+    if ($nid = i18n_node_l($matches[2], $lang)) {
+      $url = "node/$nid";
+    }
+  }
+  elseif (preg_match("/^(taxonomy\/term\/)([^\/]*)$/",$url,$matches)) {//or at a taxonomy-listing?
+    if ($str_tids = i18n_taxonomy_l($matches[2], $lang)) {
+      $url = "taxonomy/term/$str_tids";
+    }
+  }
+  
+  // $result= l($text, $url, $attributes, $query);
   return '<a href="'. i18n_url($url, $lang, $query) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
 }
 
Index: i18n_node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n_node.inc,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 i18n_node.inc
--- i18n_node.inc	8 Dec 2004 17:19:00 -0000	1.2.2.1
+++ i18n_node.inc	21 Jan 2005 16:50:20 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: i18n_node.inc,v 1.2.2.1 2004/12/08 17:19:00 jareyero Exp $
+// $Id: i18n_node.inc,v 1.1.2.1 2004/12/24 11:11:49 ber Exp $
 
 /**
  * Internationalization (i18n) module
@@ -177,6 +177,13 @@
   }
   //debug($items);
   return $items;
+}
+
+/* returns an url-part, pointing to the translated node, if exists */
+function i18n_node_l($nid, $lang) {
+  $sql = 'SELECT n.nid FROM {node} n INNER JOIN {i18n_node} a ON n.nid = a.nid INNER JOIN {i18n_node} b ON a.trid = b.trid AND b.nid =%d WHERE n.nid != %d AND n.language = \'%s\'';
+  $result = db_fetch_object(db_query($sql, $nid, $nid, $lang));
+  return $result->nid;
 }
 
 // snid = source nid
Index: i18n_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n_taxonomy.inc,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 i18n_taxonomy.inc
--- i18n_taxonomy.inc	8 Dec 2004 17:19:00 -0000	1.2.2.1
+++ i18n_taxonomy.inc	21 Jan 2005 16:50:20 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: i18n_taxonomy.inc,v 1.2.2.1 2004/12/08 17:19:00 jareyero Exp $
+// $Id: i18n_taxonomy.inc,v 1.1.2.1 2004/12/24 11:11:49 ber Exp $
 
 /**
  * Internationalization (i18n) module
@@ -196,6 +196,31 @@
   return $output;
 }
 
+/* Returns an url for the translated taxonomy-page, if exists */
+function i18n_taxonomy_l($str_tids, $lang) {
+  if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) {
+    $separator = '+';
+    // The '+' character in a query string may be parsed as ' '.
+    $tids = preg_split('/[+ ]/', $str_tids);
+  }
+  else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str_tids)) {
+    $separator = ',';
+    $tids = explode(',', $str_tids);
+  }
+  else {
+    return;
+  }
+  
+  $translated_tids = array();
+  foreach ($tids as $tid) {
+    if ($translated_tid = i18n_term_get_translations($tid)) {
+      $translated_tids[] = $translated_tid[$lang]->tid;
+    }
+  }
+  
+  return implode($separator, $translated_tids);
+}
+
 function i18n_taxonomy_where_sql($table, $type, $param = '') {
   //debug("$table $type $param");
   switch ($type) {
@@ -253,7 +278,7 @@
     $result = db_query($sql, $tid);
   }
   else {
-    $result = db_query($sql. ' and a.tid != %d', $tid);
+    $result = db_query($sql. ' and a.tid != %d', $tid, $tid);
   }
   while ($data = db_fetch_object($result)) {
     $list[$data->language] = $data;
@@ -324,5 +349,5 @@
   }
 
 } 
- 
+
 ?>
