Index: pathauto.module =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/pathauto.module,v retrieving revision 1.126.2.36 diff -u -r1.126.2.36 pathauto.module --- pathauto.module 9 Aug 2010 18:03:06 -0000 1.126.2.36 +++ pathauto.module 15 Aug 2010 20:58:36 -0000 @@ -425,6 +425,13 @@ * An optional array of additional options. */ function pathauto_taxonomy_term_update_alias($term, $op, $options = array()) { + static $languages; + if(!$languages) { + $languages = array(); + if (module_exists('locale')) { + $languages = array('' => t('Language neutral')) + locale_language_list('name'); + } + } $options += array('alias children' => FALSE); $module = 'taxonomy'; @@ -438,8 +445,17 @@ } module_load_include('inc', 'pathauto'); - $source = taxonomy_term_path($term); - pathauto_create_alias($module, $op, $source, array('taxonomy' => $term), $term->tid, $term->vid); + if($module == 'taxonomy' && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE && count($languages)) { + foreach(array_keys($languages) as $language_code) { + $term->language = $language_code; + $source = taxonomy_term_path($term); + pathauto_create_alias($module, $op, $source, array('taxonomy' => $term), $term->tid, $term->vid, $term->language); + } + } else { + $source = taxonomy_term_path($term); + pathauto_create_alias($module, $op, $source, array('taxonomy' => $term), $term->tid, $term->vid); + } + if (!empty($options['alias children'])) { // For all children generate new alias. Index: pathauto.pathauto.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/pathauto.pathauto.inc,v retrieving revision 1.1.2.6 diff -u -r1.1.2.6 pathauto.pathauto.inc --- pathauto.pathauto.inc 9 Aug 2010 18:24:25 -0000 1.1.2.6 +++ pathauto.pathauto.inc 15 Aug 2010 20:58:36 -0000 @@ -105,12 +105,29 @@ $vocabularies = taxonomy_get_vocabularies(); if (count($vocabularies)) { $settings['patternitems'] = array(); + $languages = array(); + if (module_exists('locale')) { + $languages = array('' => t('Language neutral')) + locale_language_list('name'); + } foreach ($vocabularies as $vid => $vocabulary) { if ($vid == variable_get('forum_nav_vocabulary', '')) { // Skip the forum vocabulary. continue; } - $settings['patternitems'][$vid] = t('Pattern for all %vocab-name paths', array('%vocab-name' => $vocabulary->name)); + if (function_exists('i18ntaxonomy_vocabulary') && (i18ntaxonomy_vocabulary($vid) == I18N_TAXONOMY_TRANSLATE || i18ntaxonomy_vocabulary($vid) == I18N_TAXONOMY_LOCALIZE) && count($languages)) { + $settings['patternitems'][$vid] = t('Default pattern for all %vocab-name paths (applies to all %vocab-name node types with blank patterns below)', array('%vocab-name' => $vocabulary->name)); + foreach ($languages as $lang_code => $lang_name) { + if (!empty($lang_code)) { + $settings['patternitems'][$vid .'_'. $lang_code] = t('Pattern for all %vocab-name paths in @language', array('%vocab-name' => $vocabulary->name, '@language' => $lang_name)); + } + else { + $settings['patternitems'][$vid .'_'. $lang_code] = t('Pattern for all language neutral %vocab-name paths', array('%vocab-name' => $vocabulary->name)); + } + } + } + else { + $settings['patternitems'][$vid] = t('Pattern for all %vocab-name paths', array('%vocab-name' => $vocabulary->name)); + } } } return (object) $settings; Index: pathauto.tokens.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/Attic/pathauto.tokens.inc,v retrieving revision 1.1.2.10 diff -u -r1.1.2.10 pathauto.tokens.inc --- pathauto.tokens.inc 11 Aug 2010 19:30:27 -0000 1.1.2.10 +++ pathauto.tokens.inc 15 Aug 2010 20:58:36 -0000 @@ -19,12 +19,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['node']['i18n-termpath'] = t('As [i18n-term], but including its supercategories separated by /.'); + $tokens['node']['i18n-termpath-raw'] = t('Unescaped [i18n-term], but including its supercategories separated by /. WARNING - raw user input.'); + } } } if (module_exists('book')) { @@ -60,6 +72,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 { @@ -86,14 +101,30 @@ module_load_include('inc', 'pathauto'); $parents = taxonomy_get_parents_all($object->tid); $catpath = $catpath_raw = array(); + $i18ncatpath = $i18ncatpath_raw = array(); foreach ($parents as $parent) { $term_name_cleaned = pathauto_cleanstring($parent->name); array_unshift($catpath, check_plain($term_name_cleaned)); array_unshift($catpath_raw, $term_name_cleaned); + if (module_exists('i18ntaxonomy')) { + $i18n_term_name_cleaned = pathauto_cleanstring(i18nstrings("taxonomy:term:$parent->tid:name", $parent->name, $object->language)); + array_unshift($i18ncatpath, check_plain($i18n_term_name_cleaned)); + array_unshift($i18ncatpath_raw, $i18n_term_name_cleaned); + } } $values[$label . 'path'] = implode('/', $catpath); $values[$label . 'path-raw'] = implode('/', $catpath_raw); + $values['i18n-' . $label . 'path'] = implode('/', $i18ncatpath); + $values['i18n-' . $label . 'path-raw'] = implode('/', $i18ncatpath_raw); + if (module_exists('i18ntaxonomy')) { + $values['i18n-cat'] = check_plain(i18nstrings("taxonomy:term:$object->tid:name", $object->name, $object->language)); + $values['i18n-cat-raw'] = i18nstrings("taxonomy:term:$object->tid:name", $object->name, $object->language); + + $vocab = taxonomy_vocabulary_load($object->vid); + $values['i18n-vocab'] = check_plain(i18nstrings("taxonomy:vocabulary:$vocab->vid:name", $vocab->name, $object->language)); + $values['i18n-vocab-raw'] = i18nstrings("taxonomy:vocabulary:$vocab->vid:name", $vocab->name, $object->language); + } // 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']);