Index: pathauto.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto.inc,v
retrieving revision 1.51
diff -u -p -r1.51 pathauto.inc
--- pathauto.inc	21 Mar 2009 00:24:28 -0000	1.51
+++ pathauto.inc	2 Jul 2009 11:50:21 -0000
@@ -142,12 +142,13 @@ function _pathauto_alias_exists($alias, 
  *   An array with the keys "pid" and "old_alias" containing
  *   the "pid" and old "alias", respectively, of the old alias.
  */
-function _pathauto_existing_alias_data($src) {
+function _pathauto_existing_alias_data($src, $language = '') {
   $output = array(
     'pid' => '',
     'old_alias' => ''
-  );
-  $result = db_query("SELECT pid, dst FROM {url_alias} WHERE src='%s'", $src);
+  );                                                         
+  
+  $result = db_query("SELECT pid, dst FROM {url_alias} WHERE src='%s' AND language='%s'", $src, $language); 
   if ($data = db_fetch_object($result)) {
     // The item is already aliased, check what to do...
     switch (variable_get('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE)) {
@@ -308,7 +309,7 @@ function pathauto_create_alias($module, 
     $term_path = taxonomy_term_path(taxonomy_get_term($entity_id));
     if ($term_path != $src) {
       // Quietly alias 'taxonomy/term/[tid]' with proper path for term.
-      $update_data = _pathauto_existing_alias_data($src);
+      $update_data = _pathauto_existing_alias_data($src, $language);
       _pathauto_set_alias($src, $term_path, $module, $entity_id, $update_data['pid'], FALSE, $update_data['old_alias'], $language);
       // Set $src as proper path.
       $src = $term_path;
@@ -323,7 +324,7 @@ function pathauto_create_alias($module, 
       // Do nothing
       return '';
     }
-    $update_data = _pathauto_existing_alias_data($src);
+    $update_data = _pathauto_existing_alias_data($src, $language);
     $pid = $update_data['pid'];
     $old_alias = $update_data['old_alias'];
   }
@@ -349,7 +350,7 @@ function pathauto_create_alias($module, 
   // Make sure we're not ending the alias in the middle of a word.
   $alias = _pathauto_truncate_chars($alias, $maxlength, $separator);
 
-  // If the alias already exists, generate a new, hopefully unique, variant
+  // If the alias already exists, generate a new, hopefully unique, variant            
   if (_pathauto_alias_exists($alias, $src, $language)) {
     $original_alias = $alias;
     for ($i = 0; _pathauto_alias_exists(drupal_substr($alias, 0, $maxlength - strlen($i)) . $separator . $i, $src, $language); $i++) {
@@ -375,11 +376,11 @@ function pathauto_create_alias($module, 
 
     // For forums and taxonomies, the src doesn't always form the base of the rss feed (ie. image galleries)
     if ($module == 'taxonomy' || $module == 'forum') {
-      $update_data = _pathauto_existing_alias_data("taxonomy/term/$entity_id/$feedappend");
+      $update_data = _pathauto_existing_alias_data("taxonomy/term/$entity_id/$feedappend", $language);
       _pathauto_set_alias("taxonomy/term/$entity_id/$feedappend", "$alias/feed", $module, $entity_id, $update_data['pid'], $verbose, $update_data['old_alias'], $language);
     }
     else {
-      $update_data = _pathauto_existing_alias_data("$src/$feedappend");
+      $update_data = _pathauto_existing_alias_data("$src/$feedappend", $language);
       _pathauto_set_alias("$src/$feedappend", "$alias/feed", $module, $entity_id, $update_data['pid'], $verbose, $update_data['old_alias'], $language);
     }
   }
Index: pathauto.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto.module,v
retrieving revision 1.124
diff -u -p -r1.124 pathauto.module
--- pathauto.module	20 Apr 2009 22:52:37 -0000	1.124
+++ pathauto.module	2 Jul 2009 11:50:22 -0000
@@ -81,7 +81,7 @@ function _pathauto_include() {
  */
 function pathauto_token_values($type, $object = NULL) {
   if (module_exists('taxonomy')) {
-    if ($type == 'taxonomy' || $type == 'node' || $type == 'all') {
+    if ($type == 'taxonomy' || $type == 'node' || $type == 'all') {                            
       _pathauto_include();
       switch ($type) {
         case 'node':
@@ -130,7 +130,9 @@ function pathauto_token_values($type, $o
             $values[$label .'alias'] = drupal_get_path_alias('taxonomy/term/'. $category->tid);
             if (!strncasecmp($values[$label .'alias'], 'taxonomy', 8)) {
               $values[$label .'alias'] = check_plain($category->name);
-            }
+            }          
+            $values['i18n-cat'] = check_plain(tt("taxonomy:term:$category->tid:name", $category->name, $category->language));
+            $values['i18n-cat-raw'] = tt("taxonomy:term:$category->tid:name", $category->name, $category->language);            
           }
           else { // Provide some defaults if they aren't set.
             $values[$label .'path'] = '';
@@ -152,7 +154,9 @@ function pathauto_token_list($type = 'al
     if ($type == 'taxonomy' || $type == 'all') {
       $tokens['taxonomy']['catpath'] = t('As [cat], but including its supercategories separated by /.');
       $tokens['taxonomy']['catpath-raw'] = t('As [cat-raw], but including its supercategories separated by /. WARNING - raw user input.');
-      $tokens['taxonomy']['catalias'] = t('URL alias for the term.');
+      $tokens['taxonomy']['catalias'] = t('URL alias for the term.');       
+      $tokens['taxonomy']['i18n-cat-raw'] = t("Unescaped category name translated using i18n");
+      $tokens['taxonomy']['i18n-cat'] = t("Category name translated using i18n");      
     }
     if ($type == 'node' || $type == 'all') {
       $tokens['node']['termpath'] = t('As [term], but including its supercategories separated by /.');
Index: pathauto_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto_taxonomy.inc,v
retrieving revision 1.41
diff -u -p -r1.41 pathauto_taxonomy.inc
--- pathauto_taxonomy.inc	28 Aug 2008 16:14:06 -0000	1.41
+++ pathauto_taxonomy.inc	2 Jul 2009 11:50:22 -0000
@@ -36,11 +36,29 @@ function taxonomy_pathauto($op) {
       if (sizeof($vocabularies) > 0) {
         $settings['patternitems'] = array();
         $forum_vid = variable_get('forum_nav_vocabulary', '');
+        if (module_exists('locale')) {
+          $languages = array('' => t('Language neutral')) + locale_language_list('name');
+        }
+        else {
+          $languages = array();
+        }
         foreach ($vocabularies as $vocab) {
           if ($vocab->vid != $forum_vid) {
             $vocabname = $vocab->name;
-            $fieldlabel = t('Pattern for all %vocab-name paths', array('%vocab-name' => $vocabname));
-            $settings['patternitems'][$vocab->vid] = $fieldlabel;
+            if (function_exists('i18ntaxonomy_vocabulary') && (i18ntaxonomy_vocabulary($vocab->vid) == I18N_TAXONOMY_TRANSLATE || i18ntaxonomy_vocabulary($vocab->vid) == I18N_TAXONOMY_LOCALIZE) && count($languages)) {
+              $settings['patternitems'][$vocab->vid] = t('Default pattern for all %vocab-name paths (applies to all %vocab-name node types with blank patterns below)', array('%vocab-name' => $vocabname));
+              foreach ($languages as $lang_code => $lang_name) {
+                if (!empty($lang_code)) {
+                  $settings['patternitems'][$vocab->vid .'_'. $lang_code] = t('Pattern for all %vocab-name paths in @language', array('%vocab-name' => $vocabname, '@language' => $lang_name));
+                }
+                else {
+                  $settings['patternitems'][$vocab->vid .'_'. $lang_code] = t('Pattern for all language neutral %vocab-name paths', array('%vocab-name' => $vocabname));
+                }
+              }
+            }
+            else {
+              $settings['patternitems'][$vocab->vid] = t('Pattern for all %vocab-name paths', array('%vocab-name' => $vocabname));
+            }
           }
         }
       }
@@ -80,7 +98,7 @@ function taxonomy_pathauto_bulkupdate() 
   // Exclude the forums and join all the args into one array so they can be passed to db_query
   $forum_vid[] = variable_get('forum_nav_vocabulary', '');
   $query_args = array_merge($forum_vid, $pattern_vids);
-  $query = "SELECT tid, vid, name, src, dst FROM {term_data} LEFT JOIN {url_alias} ON CONCAT('taxonomy/term/', CAST(tid AS CHAR)) = src WHERE src IS NULL AND vid <> %d ". $vid_where;
+  $query = "SELECT td.*, src, dst FROM {term_data} td LEFT JOIN {url_alias} ON CONCAT('taxonomy/term/', CAST(tid AS CHAR)) = src WHERE src IS NULL AND vid <> %d ". $vid_where;
   $result = db_query_range($query, $query_args, 0, variable_get('pathauto_max_bulk_update', 50));
 
   $count = 0;
@@ -102,6 +120,17 @@ function taxonomy_pathauto_bulkupdate() 
  */
 function _taxonomy_pathauto_alias($category, $op) {
   $count = 0;
+  static $languages;
+  
+  if(!$languages) {
+    if (module_exists('locale')) {
+      $languages = array('' => t('Language neutral')) + locale_language_list('name');
+    }
+    else {
+      $languages = array();
+    }    
+  }  
+  
 
   $placeholders = pathauto_get_placeholders('taxonomy', $category);
 
@@ -113,10 +142,21 @@ function _taxonomy_pathauto_alias($categ
       $count++;
     }
   }
-  else {
-    $src = taxonomy_term_path($category);
-    if (pathauto_create_alias('taxonomy', $op, $placeholders, $src, $category->tid, $category->vid)) {
-      $count++;
+  else {              
+    if(i18ntaxonomy_vocabulary($category->vid) == I18N_TAXONOMY_LOCALIZE && count($languages)) {
+      foreach(array_keys($languages) as $language_code) {       
+        $category->language = $language_code;
+        $placeholders = pathauto_get_placeholders('taxonomy', $category);
+        $src = taxonomy_term_path($category->tid);
+        if (pathauto_create_alias('taxonomy', $op, $placeholders, $src, $category->tid, $category->vid, $category->language)) {
+          $count++;
+        }        
+      }
+    } else {
+      $src = taxonomy_term_path($category->tid);
+      if (pathauto_create_alias('taxonomy', $op, $placeholders, $src, $category->tid, $category->vid, $category->language)) {
+        $count++;
+      }
     }
   }
   return $count;
