diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 5beadb8..3a92be1 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\Search; +use Drupal\Core\Annotation\Translation; use Drupal\Core\Config\Config; use Drupal\Core\Database\Connection; use Drupal\Core\Database\Query\SelectExtender; @@ -29,7 +30,7 @@ * * @SearchPlugin( * id = "node_search", - * title = "Content", + * title = @Translation("Content"), * path = "node" * ) */ diff --git a/core/modules/search/lib/Drupal/search/Annotation/SearchPlugin.php b/core/modules/search/lib/Drupal/search/Annotation/SearchPlugin.php index b8ea0ad..0409597 100644 --- a/core/modules/search/lib/Drupal/search/Annotation/SearchPlugin.php +++ b/core/modules/search/lib/Drupal/search/Annotation/SearchPlugin.php @@ -39,9 +39,12 @@ class SearchPlugin extends Plugin { /** * The title for the search page tab. * + * @todo: This will potentially be translated twice or cached with the wrong + * translation until the search tabs are converted to local task plugins. + * * @ingroup plugin_translatable * - * @var string + * @var \Drupal\Core\Annotation\Translation */ public $title; } diff --git a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php index a991eec..b15ffa5 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php @@ -99,7 +99,7 @@ public function getFormID() { protected function getOptions() { $options = array(); foreach ($this->searchPluginManager->getDefinitions() as $plugin_id => $search_info) { - $options[$plugin_id] = t($search_info['title']) . ' (' . $plugin_id . ')'; + $options[$plugin_id] = $search_info['title'] . ' (' . $plugin_id . ')'; } asort($options, SORT_STRING); return $options; diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php index 64d9eb9..764e546 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -12,6 +12,13 @@ class SearchRankingTest extends SearchTestBase { /** + * A node serarch plugin instance. + * + * @var \Drupal\node\Plugin\Search\NodeSearch + */ + protected $nodeSearchPlugin; + + /** * Modules to enable. * * @var array @@ -26,6 +33,16 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ + function setUp() { + parent::setUp(); + + // Create a plugin instance. + $this->nodeSearchPlugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); + } + function testRankings() { // Login with sufficient privileges. $this->drupalLogin($this->drupalCreateUser(array('post comments', 'skip comment approval', 'create page content'))); @@ -63,7 +80,7 @@ function testRankings() { } // Update the search index. - $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); + $this->nodeSearchPlugin->updateIndex(); search_update_totals(); // Refresh variables after the treatment. @@ -102,9 +119,8 @@ function testRankings() { variable_set('node_rank_' . $var, $var == $node_rank ? 10 : 0); } // Do the search and assert the results. - $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); - $plugin->setSearch('rocks', array(), array()); - $set = $plugin->execute(); + $this->nodeSearchPlugin->setSearch('rocks', array(), array()); + $set = $this->nodeSearchPlugin->execute(); $this->assertEqual($set[0]['node']->id(), $nodes[$node_rank][1]->id(), 'Search ranking "' . $node_rank . '" order.'); } } @@ -148,7 +164,7 @@ function testHTMLRankings() { } // Update the search index. - $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); + $this->nodeSearchPlugin->updateIndex(); search_update_totals(); // Refresh variables after the treatment. @@ -159,10 +175,9 @@ function testHTMLRankings() { foreach ($node_ranks as $node_rank) { variable_set('node_rank_' . $node_rank, 0); } - $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); - $plugin->setSearch('rocks', array(), array()); + $this->nodeSearchPlugin->setSearch('rocks', array(), array()); // Do the search and assert the results. - $set = $plugin->execute(); + $set = $this->nodeSearchPlugin->execute(); // Test the ranking of each tag. foreach ($sorted_tags as $tag_rank => $tag) { @@ -181,15 +196,14 @@ function testHTMLRankings() { $node = $this->drupalCreateNode($settings); // Update the search index. - $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); + $this->nodeSearchPlugin->updateIndex(); search_update_totals(); // Refresh variables after the treatment. $this->refreshVariables(); - $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); - $plugin->setSearch('rocks', array(), array()); + $this->nodeSearchPlugin->setSearch('rocks', array(), array()); // Do the search and assert the results. - $set = $plugin->execute(); + $set = $this->nodeSearchPlugin->execute(); // Ranking should always be second to last. $set = array_slice($set, -2, 1); @@ -222,7 +236,7 @@ function testDoubleRankings() { $node = $this->drupalCreateNode($settings); // Update the search index. - $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); + $this->nodeSearchPlugin->updateIndex(); search_update_totals(); // Refresh variables after the treatment. @@ -237,10 +251,9 @@ function testDoubleRankings() { } // Do the search and assert the results. - $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); - $plugin->setSearch('rocks', array(), array()); + $this->nodeSearchPlugin->setSearch('rocks', array(), array()); // Do the search and assert the results. - $set = $plugin->execute(); + $set = $this->nodeSearchPlugin->execute(); $this->assertEqual($set[0]['node']->id(), $node->id(), 'Search double ranking order.'); } } diff --git a/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php index 673b2e4..9b40e45 100644 --- a/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php +++ b/core/modules/search/tests/modules/search_extra_type/lib/Drupal/search_extra_type/Plugin/Search/SearchExtraTypeSearch.php @@ -7,6 +7,7 @@ namespace Drupal\search_extra_type\Plugin\Search; +use Drupal\Core\Annotation\Translation; use Drupal\Core\Config\Config; use Drupal\search\Plugin\SearchPluginBase; use Drupal\search\Annotation\SearchPlugin; @@ -17,7 +18,7 @@ * * @SearchPlugin( * id = "search_extra_type_search", - * title = "Dummy search type", + * title = @Translation("Dummy search type"), * path = "dummy_path" * ) */ diff --git a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php index 5a5f6a4..52ed50b 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\Search; +use Drupal\Core\Annotation\Translation; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -22,7 +23,7 @@ * * @SearchPlugin( * id = "user_search", - * title = "Users", + * title = @Translation("Users"), * path = "user" * ) */