I am returning a subset of data using a preprocessor and entityQuery:
$query = Drupal::entityQuery('node'); $query->accessCheck(FALSE) ->condition('type', 'news') ->sort('changed', 'DESC') ->range(0, 9); $nids = $query->execute(); $entities = Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
Some of these articles may have translations, and I want to return or select the translated version where available. Currently it shows the main language. I already know the language code (say en-uk) in my preprocessor.