If you have translated vocabulary (via translation sets) with terms hierarchy and try to edit term on language different from current site language, you'll see what "Relations" form part (where HS control appear) doesn't fill with parent terms.

I have patches for this problem, see attach.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Andrew Answer created an issue. See original summary.

Andrew Answer’s picture

Title: HS 18n_taxonomy terms not translated » HS 18n_taxonomy translated terms not fill parent items in hierarchy
skylord’s picture

Status: Active » Needs review
FileSize
4.52 KB

Suffered from the same issue - thanks for patch, it works OK! Recreated it for easy using.

skylord’s picture

Version: 7.x-3.0-beta2 » 7.x-3.0-beta8
andrey.troeglazov’s picture

Assigned: Unassigned » andrey.troeglazov

  • Andrew Answer authored b51e5d2 on 7.x-3.x
    Issue #2636804 by Andrew Answer, skylord, andrey.troeglazov: HS...
andrey.troeglazov’s picture

Assigned: andrey.troeglazov » Unassigned
Status: Needs review » Fixed

Thanks guys.

m.lebedev’s picture

Status: Fixed » Needs work

I have problems with the hierarchy of terms after applied the patch. When I edit a term the field of Relations shows empty sections on the taxonomy term form.

I found that terms disappear after execute this code:

  // Unset the term that's being excluded, if it is among the terms.
  if (isset($params['exclude_tid'])) {
    $excluded_term = taxonomy_term_load($params['exclude_tid']);

    foreach ($terms as $key => $term) {
      if ($term->tid == $params['exclude_tid']) {
        unset($terms[$key]);
      }
      // Provide support for translated items
      if (module_exists('i18n_taxonomy') && $term->tid != 0) {
        $terms[$key] = i18n_taxonomy_term_get_translation($term, $excluded_term->language);
      }
    }
  }

$excluded_term->language
The term may include a language that is different from other terms. After that, other terms will not be translated correctly. The items will be empty.

I think that translation of terms should be located in function _hs_taxonomy_hierarchical_select_terms_to_options and it is on there already.
I also checked that there is no such problem in the green version of the module.

My tests:
Term 1 (und)
->Term 2 (en)
->Term 3 (other)

Term 1 (other)
->Term 2 (und)
->Term 3 (en)

and etc.

Are you sure that the problem existed before applying the patch?

andrey.troeglazov’s picture

Hello, thank you for noticing I will recheck it.

skylord’s picture

Are you sure that the problem existed before applying the patch?

Of course!
I can't fully understand your case. In my case i have taxonomy vocabulary in two languages (no language neutral items) - English and Russian. When i try to edit any english term while site interface is switched to russian - i get an error mentioned in first post. Patch solves it for me.

m.lebedev’s picture

Извиняюсь за русский.

Предлагаю починить совместными усилиями.
Запустил дев версию модуля на своем проекте и получил ровно то, с чем борется этот патч.
Откатил на зеленую версию и пытался воспроизвести данную ошибку, путем смены языка терминов. Ошибок не обнаружил.
После посмотрел строчку:

     $vocabulary = taxonomy_vocabulary_load($vid);
     if (title_field_replacement_enabled('taxonomy_term', $vocabulary->machine_name, 'name')) {
       $term_entities = taxonomy_term_load_multiple(array_keys($terms[$vid]));
     }

Поставил модуль title, повторил тесты. Снова не удалось.
Есть ли кейс чтобы воспроизвести ошибку?

skylord’s picture

Status: Needs work » Needs review
FileSize
1.39 KB

Ну можно и на русском... Исходная проблема: при редактировании термина таксономии на языке, не совпадающем с текущим языком интерфейса - криво отображается иерархия. До этого в патч исходного автора не вглядывался, просто применил и оно, вроде, заработало. Сейчас попробовал - действительно, глючит. Изучил патч - его мысль понятная, но много каких-то непонятных и non-drupal-way телодвижений. :-) Суть в том, что при наличии активного модуля i18n_select, переписываются все запросы к БД с добавлением фильтра на текущий язык - поэтому и глючит, если текущий язык не совпадает с языком термина. Ниже приложен патч, который эту проблему решает более просто и наглядно (отключает i18n_select перед запросом родительских и дочерних терминов). Попробуйте, плз. Ранее опубликованный патч предлагаю откатить, т.к. подтверждаю его глючность.

andrey.troeglazov’s picture

Я откатил патч, @m.lebedev можешь проверить что сейчас ок?
И давайте дальше на англ. продолжать, чтобы не только нам понятно было.

m.lebedev’s picture

okay!
I will do it as it will be time. Thanks.

m.lebedev’s picture

Yes. The patch works.

skylord’s picture

Version: 7.x-3.0-beta8 » 7.x-3.0-beta9
FileSize
1.39 KB

Rerolled for last release.

Gold’s picture

Status: Needs review » Needs work

Looks good. Just needs Code Standards applied. There's no expectation that the whole file will be brought up to standards but the code the patch adds/touches should, at a minimum, not introduce more non-standards compliant code.