diff --git a/src/PathProcessor/DynamicPathProcessor.php b/src/PathProcessor/DynamicPathProcessor.php index e450cf7..1f57254 100755 --- a/src/PathProcessor/DynamicPathProcessor.php +++ b/src/PathProcessor/DynamicPathProcessor.php @@ -108,6 +108,12 @@ class DynamicPathProcessor implements InboundPathProcessorInterface, OutboundPat list($view_mode, $entityType, $entityId) = $path_minus_prefix_parts; $entity = $this->entityTypeManager->getStorage($entityType)->load($entityId); if ($entity) { + // Check for a translation of the entity and load that instead if + // one is found. + $language_interface = $this->languageManager->getCurrentLanguage(); + if ($entity instanceof TranslatableInterface && $entity->hasTranslation($language_interface->getId())) { + $entity = $entity->getTranslation($language_interface->getId()); + } /** @var \Drupal\view_mode_page\ViewmodepagePatternInterface[] $patterns */ $patterns = $this->entityTypeManager->getStorage('view_mode_page_pattern')->loadByProperties(['view_mode' => $view_mode]); foreach ($patterns as $pattern) {