Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.132
diff -u -p -r1.132 path.module
--- modules/path/path.module	10 Nov 2007 12:08:22 -0000	1.132
+++ modules/path/path.module	21 Nov 2007 14:42:47 -0000
@@ -85,8 +85,14 @@ function path_admin_delete($pid = 0) {
  */
 function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '') {
   if ($path && !$alias) {
+    // We delete aliasses from the node-forms based on pid to avoid problems with languages.
+    if ($pid) {
+      db_query("DELETE FROM {url_alias} WHERE src = '%s' AND pid = %d", $path, $pid);
+    }
     // Delete based on path
-    db_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language);
+    else {
+      db_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language);
+    }
     drupal_clear_path_cache();
   }
   else if (!$path && $alias) {
@@ -96,9 +102,11 @@ function path_set_alias($path = NULL, $a
   }
   else if ($path && $alias) {
     $path = urldecode($path);
+    
     $path_count = db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language));
     $alias = urldecode($alias);
     // Alias count can only be 0 or 1.
+    
     $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language));
 
     if ($alias_count == 0) {
@@ -160,7 +168,7 @@ function path_nodeapi(&$node, $op, $arg)
         // Don't try to insert if path is NULL. We may have already set
         // the alias ahead of time.
         if (isset($node->path)) {
-          path_set_alias('node/'. $node->nid, $node->path);
+          path_set_alias('node/'. $node->nid, $node->path, NULL, $language);
         }
         break;
 
