|
@@ -55,8 +55,14 @@ class EntityReferenceLabelFormatterAjax extends EntityReferenceLabelFormatter {
|
|
|
public function viewElements(FieldItemListInterface $items, $langcode) {
|
|
|
$elements = [];
|
|
|
$output_as_link = $this->getSetting('link');
|
|
|
+ $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
|
|
|
|
|
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
|
|
|
+
|
|
|
+ if ($entity->hasTranslation($current_langcode)) {
|
|
|
+ $entity = $entity->getTranslation($current_langcode);
|
|
|
+ }
|
|
|
+
|
|
|
$label = $entity->label();
|
|
|
// If the link is to be displayed and the entity has a uri, display a
|
|
|
// link.
|