I am trying to get some node's content inside a block.
I managed to get the fields i wanted, but they are always returned in my site default language instead of the current translations (ex. /node/1 and /fr/node/1 returns the same english content instead of the translation)
It works fine for simple fields, but can't get it to work for referencedEntities :
I am inside a Block build() function :
$node = \Drupal::routeMatch()->getParameter('node');
// Simple text field : Correct value depending on language
$correctValue = $node->field_test_text->getValue();
// Paragraphs/referencedEntities
$paras = $node->get('field_paragraphes')->referencedEntities();
foreach ($paras as $para) {
// Not translated, always in default language ?
$badValue = $para->get('field_test_in_para')->getValue();
}
Thanks a lot.