Index: apachesolr_search.module =================================================================== --- apachesolr_search.module (revision 25289) +++ apachesolr_search.module (working copy) @@ -457,7 +457,7 @@ } $unclick_link = ''; unset($active); - $term = taxonomy_get_term($tid); + $term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($tid)); $new_query = clone $query; if ($active = $query->has_filter('tid', $tid)) { $contains_active = TRUE; @@ -479,7 +479,7 @@ } } $vid = substr($delta, 7); - $vocab = taxonomy_vocabulary_load($vid); + $vocab = apachesolr_search_localize_taxonomy_vocabulary(taxonomy_vocabulary_load($vid)); if (is_numeric($vid) && is_array($terms) && isset($terms[$vid]) && is_array($terms[$vid])) { ksort($terms[$vid]); $limit = isset($initial_limits['apachesolr_search'][$delta]) ? $initial_limits['apachesolr_search'][$delta] : $limit_default; @@ -557,6 +557,54 @@ } /** + * Localizes taxonomy term + * + * @param $term + * @return object + */ +function apachesolr_search_localize_taxonomy_term($term) { + if (_apachesolr_search_localize_taxonomy($term)) { + $term->name = tt("taxonomy:term:$term->tid:name", $term->name); + } + return $term; +} + +/** + * Localizes taxonomy vocabulary + * + * @param $vocab + * @return object + */ +function apachesolr_search_localize_taxonomy_vocabulary($vocab) { + if (_apachesolr_search_localize_taxonomy($vocab)) { + $vocab->name = tt("taxonomy:vocabulary:$vocab->vid:name", $vocab->name); + } + return $vocab; +} + +/** + * Detects if taxonomy object should be localized + * + * @param $obj taxonomy vocabulary or term + * @return boolean + */ +function _apachesolr_search_localize_taxonomy($obj) { + static $localize = array(); + + if (module_exists('i18ntaxonomy')) { + if (empty($localize)) { + $localize = i18ntaxonomy_vocabulary(NULL, I18N_TAXONOMY_LOCALIZE); + } + + if (in_array($obj->vid, $localize)) { + return TRUE; + } + } + + return FALSE; +} + +/** * Callback function for the 'Filter by book' facet block. */ function apachesolr_search_get_book($facet, &$options) { @@ -720,7 +768,7 @@ * Return the term name from $tid. */ function theme_apachesolr_breadcrumb_tid($tid) { - $term = taxonomy_get_term($tid); + $term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($tid)); return $term->name; }