X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FLayout%2FLayoutPluginManager.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FLayout%2FLayoutPluginManager.php;h=2cd0c689573591a414b4732cc3be1bfc0412c6df;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=a5a465293775b4b75c7d84899d44bcba1f28eb3a;hpb=9424afc6c1f518c301bf87a23c047d1873435d05;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Layout/LayoutPluginManager.php b/web/core/lib/Drupal/Core/Layout/LayoutPluginManager.php index a5a465293..2cd0c6895 100644 --- a/web/core/lib/Drupal/Core/Layout/LayoutPluginManager.php +++ b/web/core/lib/Drupal/Core/Layout/LayoutPluginManager.php @@ -13,6 +13,7 @@ use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\YamlDiscoveryDecorator; use Drupal\Core\Layout\Annotation\Layout; use Drupal\Core\Plugin\FilteredPluginManagerTrait; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Provides a plugin manager for layouts. @@ -71,6 +72,10 @@ class LayoutPluginManager extends DefaultPluginManager implements LayoutPluginMa if (!$this->discovery) { $discovery = new AnnotatedClassDiscovery($this->subdir, $this->namespaces, $this->pluginDefinitionAnnotationName, $this->additionalAnnotationNamespaces); $discovery = new YamlDiscoveryDecorator($discovery, 'layouts', $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories()); + $discovery + ->addTranslatableProperty('label') + ->addTranslatableProperty('description') + ->addTranslatableProperty('category'); $discovery = new AnnotationBridgeDecorator($discovery, $this->pluginDefinitionAnnotationName); $discovery = new ContainerDerivativeDiscoveryDecorator($discovery); $this->discovery = $discovery; @@ -140,6 +145,15 @@ class LayoutPluginManager extends DefaultPluginManager implements LayoutPluginMa if (!$definition->getDefaultRegion()) { $definition->setDefaultRegion(key($definition->getRegions())); } + // Makes sure region names are translatable. + $regions = array_map(function ($region) { + if (!$region['label'] instanceof TranslatableMarkup) { + // Region labels from YAML discovery needs translation. + $region['label'] = new TranslatableMarkup($region['label'], [], ['context' => 'layout_region']); + } + return $region; + }, $definition->getRegions()); + $definition->setRegions($regions); } /**