How do I detect the language using node alias I know to get the current language of a website:

$current_lang = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();


However, given that I have a node alias

$alias = \Drupal::service('path.alias_manager')-&gt;getAliasByPath('/node/'.$nid);


How do I get the language of that $alias node?
To get the path alias of specific language try with:

$current_lang = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();
/** @var \Drupal\Core\Path\AliasManager $aliasManager */
$aliasManager =  \Drupal::service('path.alias_manager');
$alias = $aliasManager-&gt;getAliasByPath('/node/10', $current_lang);


If you want to get the language code from alias try with:

$aliasArray = \Drupal::service('path.alias_storage')-&gt;load(['source' =&gt; '/node/' . $nid]);
$lang_code = $aliasArray['langcode'];