Getting node in theme_preprocess_node I have this code:

function material_base_preprocess_node(&amp;$variables){
    $node = $variables['node'];
    $language = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();
    $variables['username'] = $node-&gt;getOwner()-&gt;getTranslation($language)-&gt;field_name-&gt;value;
    $variables['mediums1'] = $node-&gt;getTranslation($language)-&gt;field_mediums-&gt;value;
}


this line works fine:

 $variables['username'] = $node-&gt;getOwner()-&gt;getTranslation($language)-&gt;field_name-&gt;value;


but this 

 $variables['mediums1'] = $node-&gt;getTranslation($language)-&gt;field_mediums-&gt;value;


gets error:

The website encountered an unexpected error. Please try again later.&lt;/br&gt;&lt;/br&gt;&lt;em class="placeholder"&gt;InvalidArgumentException&lt;/em&gt;: Invalid translation language (en) specified. in &lt;em class="placeholder"&gt;Drupal\Core\Entity\ContentEntityBase-&amp;gt;getTranslation()&lt;/em&gt; (line &lt;em class="placeholder"&gt;789&lt;/em&gt; of &lt;em class="placeholder"&gt;core/lib/Drupal/Core/Entity/ContentEntityBase.php&lt;/em&gt;).


Why this code works for user, but not for node and how to fix that?

this one works

$node-&gt;get('field_mediums')-&gt;entity-&gt;getTranslation($language)-&gt;name-&gt;value;
As the exception message says, there is no english translation for that node. 

The node is already in the translation that Drupal determined is the best available translation for this page.

If you do want to get a specific translation, you need to check with hasTranslation() first or use \Drupal::service('entity.repository')-&gt;getTranslationFromContext($entity, $langcode);