Commit 425d682a authored by alexpott's avatar alexpott

Issue #2580423 by giancarlosotelo, s_leu, ameymudras, Berdir: Entity reference...

Issue #2580423 by giancarlosotelo, s_leu, ameymudras, Berdir: Entity reference widgets don't display entity translations
parent cba756ad
......@@ -257,7 +257,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA
$entities = $this->entityManager->getStorage($target_type)->loadMultiple($result);
foreach ($entities as $entity_id => $entity) {
$bundle = $entity->bundle();
$options[$bundle][$entity_id] = Html::escape($entity->label());
$options[$bundle][$entity_id] = Html::escape($this->entityManager->getTranslationFromContext($entity)->label());
}
return $options;
......
......@@ -73,7 +73,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA
if ($vocabulary = Vocabulary::load($bundle)) {
if ($terms = $this->entityManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) {
foreach ($terms as $term) {
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($term->getName());
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityManager->getTranslationFromContext($term)->label());
}
}
}
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\taxonomy\Tests\TermTranslationBreadcrumbTest.
* Contains \Drupal\taxonomy\Tests\TermTranslationTest.
*/
namespace Drupal\taxonomy\Tests;
......@@ -15,7 +15,7 @@
*
* @group taxonomy
*/
class TermTranslationBreadcrumbTest extends TaxonomyTestBase {
class TermTranslationTest extends TaxonomyTestBase {
use AssertBreadcrumbTrait;
use TaxonomyTranslationTestTrait;
......@@ -86,6 +86,34 @@ public function testTranslatedBreadcrumbs() {
$term = $this->getLeafTerm();
$translated = $term->getTranslation($this->translateToLangcode);
$this->assertBreadcrumb($translated->urlInfo('canonical', ['language' => $languages[$this->translateToLangcode]]), $breadcrumb, $translated->label());
}
/**
* Test translation of terms are showed in the node.
*/
protected function testTermsTranslation() {
// Set the display of the term reference field on the article content type
// to "Check boxes/radio buttons".
entity_get_form_display('node', 'article', 'default')
->setComponent($this->termFieldName, array(
'type' => 'options_buttons',
))
->save();
$this->drupalLogin($this->drupalCreateUser(['create article content']));
// Test terms are listed.
$this->drupalget('node/add/article');
$this->assertText('one');
$this->assertText('two');
$this->assertText('three');
// Test terms translated are listed.
$this->drupalget('hu/node/add/article');
$this->assertText('translatedOne');
$this->assertText('translatedTwo');
$this->assertText('translatedThree');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment