diff --git a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php index 995de59d0dcb2ecbc68fc7807f1a4c959ae5c9c3..00cdfe22d8e0c0f215b0cca161a99fa080b75767 100644 --- a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php +++ b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php @@ -11,11 +11,14 @@ use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\StringTranslation\TranslationInterface; /** * Provides dynamic local tasks for content translation. */ class ContentTranslationLocalTasks extends DeriverBase implements ContainerDeriverInterface { + use StringTranslationTrait; /** * The base plugin ID @@ -38,10 +41,13 @@ class ContentTranslationLocalTasks extends DeriverBase implements ContainerDeriv * The base plugin ID. * @param \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager * The content translation manager. + * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation + * The translation manager. */ - public function __construct($base_plugin_id, ContentTranslationManagerInterface $content_translation_manager) { + public function __construct($base_plugin_id, ContentTranslationManagerInterface $content_translation_manager, TranslationInterface $string_translation) { $this->basePluginId = $base_plugin_id; $this->contentTranslationManager = $content_translation_manager; + $this->stringTranslation = $string_translation; } /** @@ -50,7 +56,8 @@ public function __construct($base_plugin_id, ContentTranslationManagerInterface public static function create(ContainerInterface $container, $base_plugin_id) { return new static( $base_plugin_id, - $container->get('content_translation.manager') + $container->get('content_translation.manager'), + $container->get('string_translation') ); } @@ -66,7 +73,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $base_route_name = "entity.$entity_type_id.canonical"; $this->derivatives[$translation_route_name] = array( 'entity_type' => $entity_type_id, - 'title' => 'Translate', + 'title' => $this->t('Translate'), 'route_name' => $translation_route_name, 'base_route' => $base_route_name, ) + $base_plugin_definition; diff --git a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php index f11f78385eca3df34cc05d77196e650e21169b55..0b7fe85027e6b3decc12486543b10b3ce73bd677 100644 --- a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php +++ b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php @@ -37,6 +37,7 @@ protected function setUp() { 'node' => $entity_type, ))); \Drupal::getContainer()->set('content_translation.manager', $content_translation_manager); + \Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub()); } /**