diff --git a/core/lib/Drupal/Core/Plugin/PluginBase.php b/core/lib/Drupal/Core/Plugin/PluginBase.php new file mode 100644 index 0000000..03f952a --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/PluginBase.php @@ -0,0 +1,61 @@ +translationManager()->translate($string, $args, $options); + } + + /** + * Gets the translation manager. + * + * @return \Drupal\Core\StringTranslation\TranslationInterface + * The translation manager. + */ + protected function translationManager() { + if (!$this->translationManager) { + $this->translationManager = \Drupal::getContainer()->get('string_translation'); + } + return $this->translationManager; + } + + /** + * Sets the translation manager for this plugin. + * + * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager + * The translation manager. + * + * @return self + * The plugin object. + */ + public function setTranslationManager(TranslationInterface $translation_manager) { + $this->translationManager = $translation_manager; + return $this; + } + +} diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 3ed2f6f..9d4f8dd 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -7,7 +7,7 @@ namespace Drupal\block; -use Drupal\Component\Plugin\PluginBase; +use Drupal\Core\Plugin\PluginBase; use Drupal\block\BlockInterface; use Drupal\Component\Utility\Unicode; use Drupal\Core\Language\Language; @@ -100,14 +100,14 @@ public function buildConfigurationForm(array $form, array &$form_state) { $form['label'] = array( '#type' => 'textfield', - '#title' => t('Title'), + '#title' => $this->t('Title'), '#maxlength' => 255, '#default_value' => !empty($this->configuration['label']) ? $this->configuration['label'] : $definition['admin_label'], '#required' => TRUE, ); $form['label_display'] = array( '#type' => 'checkbox', - '#title' => t('Display title'), + '#title' => $this->t('Display title'), '#default_value' => $this->configuration['label_display'] == BlockInterface::BLOCK_LABEL_VISIBLE, '#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE, );