Index: pathauto.module =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/pathauto.module,v retrieving revision 1.118.2.30 diff -u -r1.118.2.30 pathauto.module --- pathauto.module 27 Sep 2010 15:52:58 -0000 1.118.2.30 +++ pathauto.module 9 Oct 2010 17:31:24 -0000 @@ -100,12 +100,24 @@ $tokens['taxonomy']['catpath-raw'] = t('As [cat-raw], but including its supercategories separated by /.'); $tokens['taxonomy']['catalias'] = t('The URL alias of the taxonomy term.'); $tokens['taxonomy']['catalias-raw'] = t('The URL alias of the taxonomy term.'); + if (module_exists('i18ntaxonomy')) { + $tokens['taxonomy']['i18n-cat'] = t('Category name translated using i18n.'); + $tokens['taxonomy']['i18n-cat-raw'] = t('Unescaped category name translated using i18n. WARNING - raw user input.'); + $tokens['taxonomy']['i18n-catpath'] = t('As [i18n-cat], but including its supercategories separated by /.'); + $tokens['taxonomy']['i18n-catpath-raw'] = t('Unescaped [i18n-cat], but including its supercategories separated by /. WARNING - raw user input.'); + $tokens['taxonomy']['i18n-vocab'] = t('Vocabulary name translated using i18n.'); + $tokens['taxonomy']['i18n-vocab-raw'] = t('Unescaped vocabulary name translated using i18n. WARNING - raw user input.'); + } } if ($type == 'node' || $type == 'all') { $tokens['node']['termpath'] = t('As [term], but including its supercategories separated by /.'); $tokens['node']['termpath-raw'] = t('As [term-raw], but including its supercategories separated by /.'); $tokens['node']['termalias'] = t('The URL alias of the taxonomy term.'); $tokens['node']['termalias-raw'] = t('The URL alias of the taxonomy term.'); + if (module_exists('i18ntaxonomy')) { + $tokens['taxonomy']['i18n-termpath'] = t('As [i18n-term], but including its supercategories separated by /.'); + $tokens['taxonomy']['i18n-termpath-raw'] = t('Unescaped [i18n-term], but including its supercategories separated by /. WARNING - raw user input.'); + } } } if (module_exists('book')) { @@ -141,6 +153,9 @@ // This query is copied from @taxonomy_node_get_terms() $term = db_fetch_object(db_query_range('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.vid = %d ORDER BY v.weight, t.weight, t.name', $object->vid, 0, 1)); if ($term) { + // We only want to translate terms when for nodes that has a language selected as we + // wont really will be able to tell which language will be used for the token. + $term->language = $object->language; $values = array_merge($values, pathauto_token_values('taxonomy', $term, $options, 'term')); } else { @@ -165,13 +180,29 @@ module_load_include('inc', 'pathauto'); $parents = taxonomy_get_parents_all($object->tid); $catpath = $catpath_raw = array(); + $i18ncatpath = $i18ncatpath_raw = array(); foreach ($parents as $parent) { array_unshift($catpath, check_plain($parent->name)); array_unshift($catpath_raw, $parent->name); + if (module_exists('i18ntaxonomy')) { + $i18n_term_name = i18nstrings("taxonomy:term:$parent->tid:name", $parent->name, $object->language); + array_unshift($i18ncatpath, check_plain($i18n_term_name)); + array_unshift($i18ncatpath_raw, $i18n_term_name); + } } $values[$label . 'path'] = !empty($options['pathauto']) ? $catpath : implode('/', $catpath); $values[$label . 'path-raw'] = !empty($options['pathauto']) ? $catpath_raw : implode('/', $catpath_raw); - + $values['i18n-' . $label . 'path'] = !empty($options['pathauto']) ? $i18ncatpath : implode('/', $i18ncatpath); + $values['i18n-' . $label . 'path-raw'] = !empty($options['pathauto']) ? $i18ncatpath_raw : implode('/', $i18ncatpath_raw); + + if (module_exists('i18ntaxonomy')) { + $values['i18n-cat-raw'] = i18nstrings("taxonomy:term:$object->tid:name", $object->name, $object->language); + $values['i18n-cat'] = check_plain($values['i18n-cat-raw']); + + $vocab = taxonomy_vocabulary_load($object->vid); + $values['i18n-vocab-raw'] = i18nstrings("taxonomy:vocabulary:$vocab->vid:name", $vocab->name, $object->language); + $values['i18n-vocab'] = check_plain($values['i18n-vocab-raw']); + } // Token [catalias-raw] and [catalias]. $values[$label . 'alias-raw'] = drupal_get_path_alias(taxonomy_term_path($object)); $values[$label . 'alias'] = check_plain($values[$label . 'alias-raw']); Index: pathauto_taxonomy.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/Attic/pathauto_taxonomy.inc,v retrieving revision 1.39.2.5 diff -u -r1.39.2.5 pathauto_taxonomy.inc --- pathauto_taxonomy.inc 31 Jul 2010 15:57:16 -0000 1.39.2.5 +++ pathauto_taxonomy.inc 9 Oct 2010 17:31:24 -0000 @@ -36,11 +36,29 @@ 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 @@ // 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, description, 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,16 @@ */ 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); @@ -114,9 +142,22 @@ } } else { - $source = taxonomy_term_path($category); - if (pathauto_create_alias('taxonomy', $op, $placeholders, $source, $category->tid, $category->vid)) { - $count++; + if(i18ntaxonomy_vocabulary($category->vid) == I18N_TAXONOMY_LOCALIZE && count($languages)) { + foreach(array_keys($languages) as $language_code) { + if (!empty($language_code)) { + $category->language = $language_code; + $placeholders = pathauto_get_placeholders('taxonomy', $category); + $source = taxonomy_term_path($category); + if (pathauto_create_alias('taxonomy', $op, $placeholders, $source, $category->tid, $category->vid, $category->language)) { + $count++; + } + } + } + } else { + $source = taxonomy_term_path($category); + if (pathauto_create_alias('taxonomy', $op, $placeholders, $source, $category->tid, $category->vid)) { + $count++; + } } } return $count;