--- modules/taxonomy.module.orig 2006-10-17 21:01:51.000000000 +0200 +++ modules/taxonomy.module 2006-12-20 14:54:50.000000000 +0100 @@ -153,6 +153,7 @@ function taxonomy_overview_terms($vid) { $header = array(t('Name'), t('Operations')); $vocabulary = taxonomy_get_vocabulary($vid); + $vocabulary = taxonomy_translate('vocabulary', $vocabulary->vid, $vocabulary); drupal_set_title(check_plain($vocabulary->name)); $start_from = $_GET['page'] ? $_GET['page'] : 0; @@ -162,6 +163,7 @@ function taxonomy_overview_terms($vid) { $tree = taxonomy_get_tree($vocabulary->vid); foreach ($tree as $term) { + $term=taxonomy_translate('term', $term->tid, $term); $total_entries++; // we're counting all-totals, not displayed if (($start_from && ($start_from * $page_increment) >= $total_entries) || ($displayed_count == $page_increment)) { continue; } $rows[] = array(_taxonomy_depth($term->depth) . ' ' . l($term->name, "taxonomy/term/$term->tid"), l(t('edit'), "admin/taxonomy/edit/term/$term->tid", array(), $destination)); @@ -536,6 +538,7 @@ function taxonomy_term_confirm_delete_su */ function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') { $vocabulary = taxonomy_get_vocabulary($vid); + $vocabulary=taxonomy_translate('vocabulary', $vocabulary->vid, $vocabulary); $help = ($help) ? $help : $vocabulary->help; if ($vocabulary->required) { $blank = 0; @@ -584,6 +587,7 @@ function taxonomy_get_vocabularies($type $vocabularies = array(); $node_types = array(); while ($voc = db_fetch_object($result)) { + $voc=taxonomy_translate('vocabulary', $voc->vid, $voc); $node_types[$voc->vid][] = $voc->type; unset($voc->type); $voc->nodes = $node_types[$voc->vid]; @@ -673,6 +677,7 @@ function taxonomy_node_get_terms_by_voca $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight', 't', 'tid'), $vid, $nid); $terms = array(); while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $terms[$term->$key] = $term; } return $terms; @@ -688,6 +693,7 @@ function taxonomy_node_get_terms($nid, $ $result = db_query(db_rewrite_sql('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.nid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid); $terms[$nid] = array(); while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $terms[$nid][$term->$key] = $term; } } @@ -800,6 +806,7 @@ function taxonomy_get_related($tid, $key $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid); $related = array(); while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $related[$term->$key] = $term; } return $related; @@ -817,6 +824,7 @@ function taxonomy_get_parents($tid, $key $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid); $parents = array(); while ($parent = db_fetch_object($result)) { + $parent=taxonomy_translate('term', $parent->tid, $parent); $parents[$parent->$key] = $parent; } return $parents; @@ -854,6 +862,7 @@ function taxonomy_get_children($tid, $vi } $children = array(); while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $children[$term->$key] = $term; } return $children; @@ -891,6 +900,7 @@ function taxonomy_get_tree($vid, $parent $result = db_query(db_rewrite_sql('SELECT t.tid, t.*, parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $vid); while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $children[$vid][$term->parent][] = $term->tid; $parents[$vid][$term->tid][] = $term->parent; $terms[$vid][$term->tid] = $term; @@ -955,6 +965,7 @@ function taxonomy_term_count_nodes($tid, $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type); } while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $count[$type][$term->tid] = $term->c; } } @@ -996,6 +1007,7 @@ function taxonomy_get_term_by_name($name $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER('%s') LIKE LOWER(t.name)", 't', 'tid'), trim($name)); $result = array(); while ($term = db_fetch_object($db_result)) { + $term=taxonomy_translate('term', $term->tid,$term); $result[] = $term; } @@ -1027,7 +1039,9 @@ function taxonomy_get_vocabulary($vid) { */ function taxonomy_get_term($tid) { // simple cache using a static var? - return db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid)); + $term = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid)); + $term=taxonomy_translate('term', $term->tid, $term); + return $term; } function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) { @@ -1210,6 +1224,7 @@ function taxonomy_term_page($str_tids = $tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to. $names = array(); while ($term = db_fetch_object($result)) { + $term=taxonomy_translate('term', $term->tid, $term); $tids[] = $term->tid; $names[] = $term->name; } @@ -1352,6 +1367,7 @@ function taxonomy_autocomplete($vid, $st $matches = array(); while ($tag = db_fetch_object($result)) { + $tag=taxonomy_translate('term', $tag->tid, $tag); $n = $tag->name; // Commas and quotes in terms are special cases, so encode 'em. if (preg_match('/,/', $tag->name) || preg_match('/"/', $tag->name)) { @@ -1363,3 +1379,12 @@ function taxonomy_autocomplete($vid, $st exit(); } } + +function taxonomy_translate($object_type, $object_id, $object) { + $translation = module_invoke_all('taxonomy', 'translate', $object_type, $object_id); + foreach($translation as $key=>$value) { + $object->$key=$value; + } + return $object; +} +