I updated Drupal core from 7.14 to 7.15 and Views from 3.3 to 3.5 and suddenly my search_api views lists won't show the term names localized, meaning in English always. I don't think any settings have changed, but the display has. When I'm displaying the term names in other views, which are not using a search index, there is an option to show plain text, plain text(localized), link, link(localized) etc. Maybe Search API should take a similar approach? Or am I missing something?

Comments

merilainen’s picture

Priority: Normal » Major
StatusFileSize
new51.41 KB
new52.62 KB
new88.78 KB

I did some further debugging by installing vanilla Drupal and minimum required modules, only search_api_et is in dev state. In the listing, the terms always appear in their source language, exposed filters and non-search_api views show everything as I expect.

Bumping up to major to get some attention!

finex’s picture

I'm experiencing the same problem. It can be reproducible when the vocabulary is configured with the following setting:

Localize. Terms are common for all languages, but their name and description may be localized

Regular views or node display settings allow to use a special formatter "Link (localized)". But search API doesn't make use of it. Moreover this problem affects "Facet API" too.

papirrin’s picture

I have the same probem. Have you guys found a solution?

merilainen’s picture

I think the problem is in search_api because it's storing the name of the taxonomy term when it is chosen to be indexed instead of storing term ID (tid) which is more useful and can be used to get the term name in the user's language.

I came up with a quite ugly workaround using Views PHP module and processing the term ID with some php:

<?php
global $language;
$term_ids = array();
$term_ids = $data->_entity_properties['FIELD_MACHINE_NAME'];
$terms_localized = array();
foreach($term_ids as $term_id) {
  $term = taxonomy_term_load($term_id);
  // Reading localized terms using term id
  $terms_localized[] = i18n_taxonomy_term_name($term, $language->language);
}
print(implode(", ", $terms_localized));
?>

Notice that this snippet uses the i18n_taxonomy_term_name() function from i18n module.

So you include the taxonomy term field you need in the view and exclude it from display, then adding a PHP field with the snippet above will print the term in localized form.

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.