nortmas
2/3/2020 - 1:55 PM

Get field translations

<?php
// Get current language id.
$lang_code = \Drupal::service('language_manager')
  ->getCurrentLanguage()
  ->getId();
  
$accordion = $paragraph->field_accordions->referencedEntities();
/** @var \Drupal\paragraphs\Entity\Paragraph $accordion_item */
foreach ($accordion as $delta => $accordion_item) {
  if ($accordion_item->hasTranslation($lang_code)) {
    $accordion_item = $accordion_item->getTranslation($lang_code);
  }
}