diff -ur xmlsitemap.orig/xmlsitemap.module xmlsitemap/xmlsitemap.module
--- xmlsitemap.orig/xmlsitemap.module	2007-12-18 21:20:30.000000000 +0100
+++ xmlsitemap/xmlsitemap.module	2008-04-29 08:58:42.000000000 +0200
@@ -751,12 +751,9 @@
   if (!empty($alias)) {
     $result = $alias;
   }
-  if (function_exists('custom_url_rewrite')) {
+  if (function_exists('custom_url_rewrite') && !module_exists('i18n')) {
     $result = custom_url_rewrite('alias', $result, $path);
   }
-  if (module_exists('i18n')) {
-    i18n_get_lang_prefix($result, TRUE);
-  }
   return $result;
 }
 
diff -ur xmlsitemap.orig/xmlsitemap_node/xmlsitemap_node.module xmlsitemap/xmlsitemap_node/xmlsitemap_node.module
--- xmlsitemap.orig/xmlsitemap_node/xmlsitemap_node.module	2007-12-10 04:15:12.000000000 +0100
+++ xmlsitemap/xmlsitemap_node/xmlsitemap_node.module	2008-04-29 09:08:41.000000000 +0200
@@ -50,28 +50,36 @@
  */
 function _xmlsitemap_node_links($excludes = array()) {
   $links = array();
-  if (module_exists('comment')) {
-    $sql = "
-      SELECT n.nid, n.type, n.promote, s.comment_count, n.changed, xn.previously_changed, s.last_comment_timestamp, xn.previous_comment, xn.priority_override, ua.dst AS alias
-      FROM {node} n
-      LEFT JOIN {node_comment_statistics} s ON s.nid = n.nid";
+  if (module_exists('i18n')) {
+    $select_ext .= ", i18n.language AS lang";
+    $join_ext .= " LEFT JOIN {i18n_node} i18n ON n.nid = i18n.nid";
   }
-  else {
-    $sql = "
-      SELECT n.nid, n.type, n.promote, n.changed, xn.previously_changed, xn.priority_override, ua.dst AS alias
-      FROM {node} n";
+  if (module_exists('comment')) {
+    $select_ext .= ", s.comment_count, s.last_comment_timestamp, xn.previous_comment";
+    $join_ext .= " LEFT JOIN {node_comment_statistics} s ON s.nid = n.nid";
   }
-  $sql .= "
+  $sql = "
+    SELECT n.nid, n.type, n.promote, n.changed, xn.previously_changed, xn.priority_override, ua.dst AS alias $select_ext
+    FROM {node} n
     LEFT JOIN {xmlsitemap_node} xn ON xn.nid = n.nid
-    LEFT JOIN {url_alias} ua ON ua.pid = xn.pid
+    LEFT JOIN {url_alias} ua ON ua.pid = xn.pid $join_ext
     WHERE n.status > 0
     AND (n.type NOT IN ('". implode("', '", $excludes) ."') AND xn.priority_override IS NULL OR xn.priority_override >= 0)
     AND n.nid <> %d";
   $result = db_query(db_rewrite_sql($sql), _xmlsitemap_node_frontpage());
   while ($node = db_fetch_object($result)) {
+    $lang_prefix = ($node->lang) ? $node->lang.'/' : '';
+    if ($node->alias) {
+      if (substr($node->alias, 0, 3) == $lang_prefix)
+        $alias = $node->alias;
+      else
+        $alias = $lang_prefix.$node->alias;
+    } else {
+      $alias = '';
+    }
     $links[] = array(
       'nid' => $node->nid,
-      '#loc' => xmlsitemap_url('node/'. $node->nid, $node->alias, NULL, NULL, TRUE),
+      '#loc' => xmlsitemap_url($lang_prefix.'node/'. $node->nid, $alias, NULL, NULL, TRUE),
       '#lastmod' => variable_get('xmlsitemap_node_count_comments', TRUE) ? max($node->changed, $node->last_comment_timestamp) : $node->changed,
       '#changefreq' => xmlsitemap_node_frequency($node),
       '#priority' => xmlsitemap_node_priority($node),
diff -ur xmlsitemap.orig/xmlsitemap_term/xmlsitemap_term.module xmlsitemap/xmlsitemap_term/xmlsitemap_term.module
--- xmlsitemap.orig/xmlsitemap_term/xmlsitemap_term.module	2007-12-13 03:18:30.000000000 +0100
+++ xmlsitemap/xmlsitemap_term/xmlsitemap_term.module	2008-04-29 09:11:00.000000000 +0200
@@ -61,8 +61,17 @@
     AND td.tid <> %d
   ", 'td', 'tid'), _xmlsitemap_term_frontpage());
   while ($term = db_fetch_object($result)) {
+  	$lang_prefix = ($term->language) ? $term->language.'/' : '';
+    if ($term->alias) {
+      if (substr($term->alias, 0, 3) == $lang_prefix)
+        $alias = $term->alias;
+      else
+        $alias = $lang_prefix.$term->alias;
+    } else {
+      $alias = '';
+    }
     if ($term->module == 'forum') {
-      $url = xmlsitemap_url("forum/$term->tid", $term->alias, NULL, NULL, TRUE);
+      $url = xmlsitemap_url($lang_prefix."forum/$term->tid", $alias, NULL, NULL, TRUE);
     }
     elseif ($term->module != 'taxonomy' && $path = module_invoke($term->module, 'term_path', $term)) {
       $alias = drupal_lookup_path('alias', $path);
@@ -72,7 +81,7 @@
       $url = xmlsitemap_url($path, $term->alias, NULL, NULL, TRUE);
     }
     else {
-      $url = xmlsitemap_url("taxonomy/term/$term->tid", $term->alias, NULL, NULL, TRUE);
+      $url = xmlsitemap_url($lang_prefix."taxonomy/term/$term->tid", $alias, NULL, NULL, TRUE);
     }
     $age = time() - $term->last_changed;
     $interval = empty($term->previously_changed) ? 0 : $term->last_changed - $term->previously_changed;
