# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: apachesolr_search.module
--- apachesolr_search.module Base (1.1.2.6.2.111.2.93)
+++ apachesolr_search.module Locally Modified (Based On 1.1.2.6.2.111.2.93)
@@ -815,7 +815,7 @@
   }
 
   // Check that we have a response and a valid vid.
-  if (is_object($response->facet_counts->facet_fields->$delta) && ($vocab = taxonomy_vocabulary_load($vid))) {
+  if (is_object($response->facet_counts->facet_fields->$delta) && ($vocab = apachesolr_search_localize_taxonomy_vocabulary(taxonomy_vocabulary_load($vid)))) {
     $reflect_hierarchy = apachesolr_search_get_hierarchical_vocabularies();
     $contains_active = FALSE;
     $facets = array();
@@ -919,7 +919,7 @@
       // Taxonomy filters in the query string use the tid field.
       if ($field_name == 'tid') {
         // Each taxonomy vocabulary in the Solr index uses its own field.
-        $term = taxonomy_get_term($field['#value']);
+        $term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($field['#value']));
         $field_name = 'im_vid_' . $term->vid;
       }
     }
@@ -1008,7 +1008,7 @@
 
 function apachesolr_search_taxonomy_get_term($tid) {
   if (function_exists('taxonomy_get_term')) {
-    $term = taxonomy_get_term($tid);
+    $term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($tid));
     return $term->name;
   }
 }
@@ -1429,7 +1429,7 @@
  */
 function theme_apachesolr_breadcrumb_tid($field) {
   if (function_exists('taxonomy_get_term')) {
-    if ($term = taxonomy_get_term($field['#value'])) {
+    if ($term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($field['#value']))) {
       return $term->name;
     }
   }
@@ -1539,7 +1539,7 @@
     $facets = array();
     foreach ($fields as $index => $field) {
       if ($field['#name'] && 'tid' == $field['#name']) {
-        $term = taxonomy_get_term($field['#value']);
+        $term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($field['#value']));
         if ($reflect_hierarchy[$term->vid]) {
           $fields[$index] += array('#parent' => 0, '#children' => array());
           // Just save the index for later lookup.
@@ -1612,3 +1612,36 @@
 
   return $result;
 }
+
+/**
+ * Localizes a taxonomy term when applicable.
+ *
+ * @param $term
+ *   The taxonomy term object to localize.
+ * @return
+ *   A localized version of the term object, or the unchanged term if no
+ *   localization could be applied.
+ */
+function apachesolr_search_localize_taxonomy_term($term) {
+  if (is_object($term) && module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) {
+    $term->name = i18nstrings("taxonomy:term:{$term->tid}:name", $term->name);
+  }
+  return $term;
+}
+
+/**
+ * Localizes taxonomy vocabulary, if applicable.
+ *
+ * @param $vocab
+ *   The taxonomy vocabulary object to localize.
+ * @return
+ *   The localized version of the vocabulary object, or the unchanged vocabulary
+ *   if no localization could be applied.
+ */
+function apachesolr_search_localize_taxonomy_vocabulary($vocab) {
+  if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($vocab->vid) == I18N_TAXONOMY_LOCALIZE) {
+    $vocab->name = i18nstrings("taxonomy:vocabulary:{$vocab->vid}:name", $vocab->name);
+  }
+  return $vocab;
+}
+
