2c2 < index 45185ba..9924605 100644 --- > index 45185ba..80f0659 100644 23c23,68 < @@ -92,10 +95,13 @@ class EntityReference_SelectionHandler_Translation_Generic_taxonomy_term extends --- > @@ -59,6 +62,44 @@ class EntityReference_SelectionHandler_Translation_Generic_node extends EntityRe > } > > /** > + * Overrides EntityReference_SelectionHandler_Generic_node::getReferencableEntities(). > + * It only adds logic to modify label to add translation into default language if its necessary. > + */ > + public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { > + $options = array(); > + $entity_type = $this->field['settings']['target_type']; > + > + $query = $this->buildEntityFieldQuery($match, $match_operator); > + if ($limit > 0) { > + $query->range(0, $limit); > + } > + > + $results = $query->execute(); > + > + if (!empty($results[$entity_type])) { > + $entities = entity_load($entity_type, array_keys($results[$entity_type])); > + foreach ($entities as $entity_id => $entity) { > + list(,, $bundle) = entity_extract_ids($entity_type, $entity); > + $label = check_plain($this->getLabel($entity)); > + // If the term its not in default language, we add the translation into default language between parenthesis. > + if ($entity->tnid > 0) { > + $nodes = translation_node_get_translations($entity->tnid); > + $def_lang = language_default('language'); > + if ($this->field['settings']['handler_settings']['filter']['language'] == 1 && $entity->language != $def_lang && isset($nodes[$def_lang])) { > + $trans_entity = $nodes[$def_lang]; > + $trans_entity = node_load($trans_entity->nid); > + $label .= ' (' . check_plain($this->getLabel($trans_entity)) . ')'; > + } > + } > + $options[$bundle][$entity_id] = $label; > + } > + } > + > + return $options; > + } > + > + > + /** > * Overrides EntityReference_SelectionHandler_Generic::settingsForm(). > * 0 = Makes the filtering configurable. Either show all nodes (filtered on > * interface language) or show only those nodes with the same language as the > @@ -92,10 +133,13 @@ class EntityReference_SelectionHandler_Translation_Generic_taxonomy_term extends 41c86 < @@ -105,6 +111,51 @@ class EntityReference_SelectionHandler_Translation_Generic_taxonomy_term extends --- > @@ -105,6 +149,58 @@ class EntityReference_SelectionHandler_Translation_Generic_taxonomy_term extends 72a118,119 > + $def_lang = language_default('language'); > + 77,80c124,132 < + $depth = $term->depth; < + $term = i18n_taxonomy_term_get_translation($term, $lang); < + $term->depth = $depth; < + $options[$vocabulary->machine_name][$term->tid] = str_repeat('-', $term->depth) . check_plain(entity_label('taxonomy_term', $term)); --- > + $term_translated = i18n_taxonomy_term_get_translation($term, $lang); > + $term_translated->depth = $term->depth; > + $label = check_plain(entity_label('taxonomy_term', $term_translated)); > + // If the term its not in default language, we add the translation into default language between parenthesis. > + if ($this->field['settings']['handler_settings']['filter']['language'] == 1 && $lang != $def_lang) { > + $term_default_lang = i18n_taxonomy_term_get_translation($term, $def_lang); > + $label .= ' (' . check_plain(entity_label('taxonomy_term', $term_default_lang)) . ')'; > + } > + $options[$vocabulary->machine_name][$term_translated->tid] = str_repeat('-', $term_translated->depth) . $label;