From 71508f0b5eee2d877afad197ba5a8a35a18a71d9 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Mon, 2 Sep 2013 14:27:40 -0700 Subject: [PATCH] Issue #2079477 by ParisLiakos: Fixed ForumManager and ForumController use ->translationManager->translate() instead of ->t(). --- .../forum/Controller/ForumController.php | 19 ++++++++++++++----- .../forum/lib/Drupal/forum/ForumManager.php | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php index a0db5d2488eb..131c1fe5634f 100644 --- a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php @@ -11,7 +11,7 @@ use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityManager; -use Drupal\Core\StringTranslation\TranslationManager; +use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\forum\ForumManagerInterface; use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\TermStorageControllerInterface; @@ -61,7 +61,7 @@ class ForumController implements ContainerInjectionInterface { /** * Translation manager service. * - * @var \Drupal\Core\StringTranslation\TranslationManager + * @var \Drupal\Core\StringTranslation\TranslationInterface */ protected $translationManager; @@ -78,10 +78,10 @@ class ForumController implements ContainerInjectionInterface { * Term storage controller. * @param \Drupal\Core\Entity\EntityManager $entity_manager * The entity manager service. - * @param \Drupal\Core\StringTranslation\TranslationManager $translation_manager + * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager * The translation manager service. */ - public function __construct(Config $config, ForumManagerInterface $forum_manager, VocabularyStorageControllerInterface $vocabulary_storage_controller, TermStorageControllerInterface $term_storage_controller, EntityManager $entity_manager, TranslationManager $translation_manager) { + public function __construct(Config $config, ForumManagerInterface $forum_manager, VocabularyStorageControllerInterface $vocabulary_storage_controller, TermStorageControllerInterface $term_storage_controller, EntityManager $entity_manager, TranslationInterface $translation_manager) { $this->config = $config; $this->forumManager = $forum_manager; $this->vocabularyStorageController = $vocabulary_storage_controller; @@ -143,7 +143,7 @@ public function forumIndex() { $build = $this->build($index->forums, $index); if (empty($index->forums)) { // Root of empty forum. - $build['#title'] = $this->translationManager->translate('No forums defined'); + $build['#title'] = $this->t('No forums defined'); } else { // Set the page title to forum's vocabulary name. @@ -212,4 +212,13 @@ public function addContainer() { return $this->entityManager->getForm($taxonomy_term, 'container'); } + /** + * Translates a string to the current language or to a given language. + * + * See the t() documentation for details. + */ + protected function t($string, array $args = array(), array $options = array()) { + return $this->translationManager->translate($string, $args, $options); + } + } diff --git a/core/modules/forum/lib/Drupal/forum/ForumManager.php b/core/modules/forum/lib/Drupal/forum/ForumManager.php index 0f03e635d409..92c2a7cb560d 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManager.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManager.php @@ -142,9 +142,9 @@ public function getTopics($tid) { global $user, $forum_topic_list_header; $forum_topic_list_header = array( - array('data' => $this->translationManager->translate('Topic'), 'field' => 'f.title'), - array('data' => $this->translationManager->translate('Replies'), 'field' => 'f.comment_count'), - array('data' => $this->translationManager->translate('Last reply'), 'field' => 'f.last_comment_timestamp'), + array('data' => $this->t('Topic'), 'field' => 'f.title'), + array('data' => $this->t('Replies'), 'field' => 'f.comment_count'), + array('data' => $this->t('Last reply'), 'field' => 'f.last_comment_timestamp'), ); $order = $this->getTopicOrder($sortby); @@ -548,4 +548,14 @@ public function updateIndex($nid) { ->execute(); } } + + /** + * Translates a string to the current language or to a given language. + * + * See the t() documentation for details. + */ + protected function t($string, array $args = array(), array $options = array()) { + return $this->translationManager->translate($string, $args, $options); + } + } -- GitLab