Is it possible to retrieve the title by node ID, based on the interface language.
I found drupal_url('/node/101', {absolute: true}).
I wish to have a similar function that returns a title passing a node ID.

1 Answer 1


Anyway I had to do this in preprocess function

function template_preprocess_field(&$variables) {
    $lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $variables['node_101'] = \Drupal\node\Entity\Node::load(101)->getTranslation($lang)->getTitle();
    $variables['node_75'] = \Drupal\node\Entity\Node::load(75)->getTranslation($lang)->getTitle();
    $variables['node_103'] = \Drupal\node\Entity\Node::load(103)->getTranslation($lang)->getTitle();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.