diff --git a/pathologic.module b/pathologic.module index facc6de..6929d97 100644 --- a/pathologic.module +++ b/pathologic.module @@ -294,7 +294,9 @@ function _pathologic_replace($matches) { } // Okay, deal with language stuff. - // Let's see if we can split off a language prefix from the path. + // Let's see if path has a language prefix, so we can distinguish the target + // language for this path. + $specific_language = NULL; if (\Drupal::moduleHandler()->moduleExists('language')) { // This logic is based on // \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::getLangcode(). @@ -308,8 +310,7 @@ function _pathologic_replace($matches) { // Search for prefix within added languages. foreach ($languages as $language) { if (isset($config['prefixes'][$language->getId()]) && $config['prefixes'][$language->getId()] == $prefix) { - $parts['path'] = implode('/', $path_args); - $parts['language_obj'] = $language; + $specific_language = $language; break; } } @@ -332,7 +333,7 @@ function _pathologic_replace($matches) { 'absolute' => $cached_settings['current_settings']['protocol_style'] !== 'path', // If we seem to have found a language for the path, pass it along to // url(). Otherwise, ignore the 'language' parameter. - 'language' => isset($parts['language_obj']) ? $parts['language_obj'] : NULL, + 'language' => isset($specific_language) ? $specific_language : NULL, // A special parameter not actually used by url(), but we use it to see if // an alter hook implementation wants us to just pass through the original // URL.