I have a view that includes a taxonomy term reference which I have translated using entity translation. When I show the field in views results, the translated value shows up properly. However, when the value is displayed in an exposed filter, the default language (English) is always shown. Is there a way to show translated values in exposed filters?

Comments

plach’s picture

Title: Views exposed filters- is there a way to make translated taxonomy terms display based on page language? » Views exposed filters - is there a way to make translated taxonomy terms display based on page language?
Project: Entity Translation » Title
Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Component: Base system » Code
Category: support » feature

This is a Title-Views integration issue and not an easy one, I fear.

mindaugasd’s picture

Any plans to make this work in the near future?

mindaugasd’s picture

For me things are a bit different. If I change to non-default language nothing shows up in the exposed filter box. I only see filter values if I choose default taxonomy language (non-english).

mindaugasd’s picture

Maybe I could use t() function to translate filters, but it is not possible than no values are shown at all in other languages.

mindaugasd’s picture

If somebody needs a solution, you can install http://drupal.org/project/i18nviews module and add the '... (translated)' Handlers to your view, then filter will be translated.

But it does not work with Title module, still no translated values shows up.

And I still need entity_translation & title modules, becouse I import terms with feeds.

payamspot’s picture

Thanks mindaugasd :) #5 Worked for me.

And for further reference: I chose "Localize. Terms are common for all languages, but their name and description may be localized. " as the "Translation mode" of the vocabulary.

jherencia’s picture

Well, I've been having this issue and have found a temporary solution for my project that could help:

function hook_query_alter(QueryAlterableInterface $query) {
  if (!module_exists('title') {
    return;
  }
  if ($query->hasTag('term_access')) {
    global $language;
    $query->innerJoin('field_data_name_field', 'title', 'title.entity_id = td.tid');
    $query->addField('title', 'name_field_value', 'name');
    $query->condition('title.language', $language->language);
    $query->condition('title.entity_type', 'taxonomy_term');
  }
}

The problems this has are:

  • It does not check if the name field has been introduced to the vocabulary so in case one of your vocabularies is not translatable empty values will appear.
  • It alters every query which has term_access tag.
tuwebo’s picture

Hello,
I am not pretty sure but maybe this patch #1651726: Use entity_label instead of term name for term reference exposed filters could help to solve this problem, although could have performance issues.

ptmkenny’s picture

Status: Active » Closed (duplicate)

Excellent! The patch in #8 worked for me! Marking this as a duplicate of #1651726.