diff --git a/sites/all/modules/figli/edlp_ajax/src/Controller/EdlpAjaxController.php b/sites/all/modules/figli/edlp_ajax/src/Controller/EdlpAjaxController.php index e39fc8740..0dd224d32 100644 --- a/sites/all/modules/figli/edlp_ajax/src/Controller/EdlpAjaxController.php +++ b/sites/all/modules/figli/edlp_ajax/src/Controller/EdlpAjaxController.php @@ -19,7 +19,17 @@ use Drupal\core\render\RenderContext; class EdlpAjaxController extends ControllerBase { private function query() { - $this->entity = entity_load($this->entity_type, $this->id); + $this->langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); + + + $entity = entity_load($this->entity_type, $this->id); + + if ($entity->hasTranslation($this->langcode)){ + $this->entity = $entity->getTranslation($this->langcode); + }else{ + $this->entity = $entity; + } + if($this->entity){ switch($this->entity_type){ @@ -174,6 +184,7 @@ class EdlpAjaxController extends ControllerBase { 'bundle' => $this->bundle, 'entity_type' => $this->entity_type, 'rendered'=> $rendered, + 'language' => $this->langcode ]; // if content type page (productions) : @@ -227,6 +238,9 @@ class EdlpAjaxController extends ControllerBase { 'tags' => [ 'edlp-ajax-cache', // $this->entity_type.':'.$this->id // not necessary as we add $renderable as CacheableMetadata to the response + ], + 'contexts' => [ + 'languages:language_content' ] ];