Hi,

Problem

Actually, I created a webform on a multilingue project which contains a component using Term select.

This component is linked to a vocabulary, some of terms are translated.

When i printed my webform, I saw that in list terms options, terms name are printed in the original language but not with the current language of the page.

Proposed resolution

Before the term name is get:

  • Check if the term is translatable and has a translation to get it
  • Use the name of the translatable term instead of the original name.

Please see the attached patch in my next comment.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Tsymi created an issue. See original summary.

Tsymi’s picture

Status: Needs review » Needs work
Tsymi’s picture

Sorry, please find my patch fixed.

Status: Needs review » Needs work
Tsymi’s picture

Patch attached with another fix.

jrockowitz’s picture

The only tweak that I am going to make is change...

        if ($item->isTranslatable()) {
          if ($item->hasTranslation($language)) {
            $item = $item->getTranslation($language);
          }
          else {
            continue;
          }
        }

...to...

        if ($item->isTranslatable() && $item->hasTranslation($language)) {
            $item = $item->getTranslation($language);
        }

...because as general rule, it is okay to let the source language bleed through when there is no translation. If a vocabulary had no translated terms the menu would be empty or if a parent term is missing a translation, the menu would appear broken.

jrockowitz’s picture

  • jrockowitz committed 31ff1e1 on 8.x-5.x
    Issue #2862845 by Tsymi, jrockowitz: Print term select reference...
jrockowitz’s picture

Status: Needs review » Fixed

@Tsymi thanks for the patch.

I committed the latest patch. Please download and review the latest dev release. Don't hesitate to post more tweaks and reopen this ticket if needed.

Tsymi’s picture

Hi jrockowitz,

Thanks for your return :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.