diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php
index 3a31917..6425579 100644
--- a/core/lib/Drupal/Core/Path/AliasManager.php
+++ b/core/lib/Drupal/Core/Path/AliasManager.php
@@ -149,11 +149,24 @@
    * {@inheritdoc}
    */
   public function getPathByAlias($alias, $langcode = NULL) {
-    // If no language is explicitly specified we default to the current URL
-    // language. If we used a language different from the one conveyed by the
-    // requested URL, we might end up being unable to check if there is a path
-    // alias matching the URL path.
-    $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
+    // If no language is explicitly specified we try to get the language code
+    // from the alias. If we used a language different from the one conveyed by
+    // the requested URL, we might end up being unable to check if there is a
+    // path alias matching the URL path.
+    if (!$langcode && $this->languageManager->isMultilingual()) {
+      $alias_args = explode('/', trim($alias, '/'));
+      $prefix = array_shift($alias_args);
+      if ($language = $this->languageManager->getLanguage($prefix)) {
+        $langcode = $language->getId();
+      }
+
+      // If the alias didn't contain a language code, we use the default language.
+      $langcode = $langcode ? : $this->languageManager->getDefaultLanguage()->getId();
+    }
+
+    // If we didn't get a language code from the alias, we default to the
+    // current language.
+    $langcode = $langcode ? : $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
 
     // If we already know that there are no paths for this alias simply return.
     if (empty($alias) || !empty($this->noPath[$langcode][$alias])) {
