diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index 288020a..b1185c6 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -188,7 +188,7 @@ public function testBlockDelete() { // Delete the block. $this->drupalGet('block/1/delete'); - $this->assertText(\Drupal::translation()->formatPlural(1, 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instance.')); + $this->assertText($this->container->get('string_translation')->formatPlural(1, 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instance.')); $this->drupalPostForm(NULL, array(), 'Delete'); $this->assertRaw(t('Custom block %name has been deleted.', array('%name' => $edit['info']))); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index 547eea9..8910777 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -197,7 +197,7 @@ function performCommentOperation($comment, $operation, $approval = FALSE) { if ($operation == 'delete') { $this->drupalPostForm(NULL, array(), t('Delete comments')); - $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); + $this->assertRaw($this->container->get('string_translation')->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); } else { $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index 82b11ef..b96a3a9 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -312,7 +312,7 @@ function performCommentOperation(CommentInterface $comment, $operation, $approva if ($operation == 'delete') { $this->drupalPostForm(NULL, array(), t('Delete comments')); - $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); + $this->assertRaw($this->container->get('string_translation')->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); } else { $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index 305800d..15ebd09 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -78,7 +78,7 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook)); } elseif ($expected_count == 0) { - $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); + $message = $this->container->get('string_translation')->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); } else { $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count)); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index 4ac19f9..1e7437f 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -167,7 +167,7 @@ function testForum() { // Verify the number of unread topics. $unread_topics = $this->container->get('forum_manager')->unreadTopics($this->forum['tid'], $this->edit_any_topics_user->id()); - $unread_topics = \Drupal::translation()->formatPlural($unread_topics, '1 new post', '@count new posts'); + $unread_topics = $this->container->get('string_translation')->formatPlural($unread_topics, '1 new post', '@count new posts'); $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]//a', $forum_arg); $this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.'); // Verify that the forum name is in the unread topics text. diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 52d32f8..f33061b 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -76,7 +76,7 @@ function testStandalonePoFile() { // The import should have created 1 string and rejected 2. $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.'); - $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', array('@url' => url('admin/reports/dblog'))); + $skip_message = $this->container->get('string_translation')->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', array('@url' => url('admin/reports/dblog'))); $this->assertRaw($skip_message, 'Unsafe strings were skipped.'); // Try importing a zero byte sized .po file. diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php index fbdbf96..d8c60d6 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php @@ -126,7 +126,7 @@ function testGetPluralFormat() { // expected index as per the logic for translation lookups. $expected_plural_index = ($count == 1) ? 0 : $expected_plural_index; $expected_plural_string = str_replace('@count', $count, $plural_strings[$langcode][$expected_plural_index]); - $this->assertIdentical(\Drupal::translation()->formatPlural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode)), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string); + $this->assertIdentical($this->container->get('string_translation')->formatPlural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode)), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string); } } } @@ -214,7 +214,7 @@ function testPluralEditExport() { // langcode here because the language will be English by default and will // not save our source string for performance optimization if we do not ask // specifically for a language. - \Drupal::translation()->formatPlural(1, '1 day', '@count days', array(), array('langcode' => 'fr')); + $this->container->get('string_translation')->formatPlural(1, '1 day', '@count days', array(), array('langcode' => 'fr')); $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", array(':source' => "1 day" . LOCALE_PLURAL_DELIMITER . "@count days"))->fetchField(); // Look up editing page for this plural string and check fields. $search = array( diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 5049865..23a8090 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1078,7 +1078,7 @@ protected function tearDown() { $captured_emails = $state->get('system.test_email_collector') ?: array(); $emailCount = count($captured_emails); if ($emailCount) { - $message = \Drupal::translation()->formatPlural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.'); + $message = $this->container->get('string_translation')->formatPlural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.'); $this->pass($message, t('E-mail')); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php index c55eaa9..a55efe4 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php @@ -149,7 +149,7 @@ function assertFailedLogin($account, $flood_trigger = NULL) { $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.'); if (isset($flood_trigger)) { if ($flood_trigger == 'user') { - $this->assertRaw(\Drupal::translation()->formatPlural(\Drupal::config('user.flood')->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); + $this->assertRaw($this->container->get('string_translation')->formatPlural(\Drupal::config('user.flood')->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); } else { // No uid, so the limit is IP-based. diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php index 0d575c1..15176dd 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php @@ -108,7 +108,7 @@ public function testAdminUserInterface() { 'options[value]' => implode(', ', $users) ); $this->drupalPostForm($path, $edit, t('Apply')); - $message = \Drupal::translation()->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); + $message = $this->container->get('string_translation')->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); $this->assertText($message); // Pass in an invalid username and a valid username. @@ -120,7 +120,7 @@ public function testAdminUserInterface() { ); $users = array($users[0]); $this->drupalPostForm($path, $edit, t('Apply')); - $message = \Drupal::translation()->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); + $message = $this->container->get('string_translation')->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); $this->assertRaw($message); // Pass in just valid usernames. @@ -130,7 +130,7 @@ public function testAdminUserInterface() { 'options[value]' => implode(', ', $users) ); $this->drupalPostForm($path, $edit, t('Apply')); - $message = \Drupal::translation()->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); + $message = $this->container->get('string_translation')->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); $this->assertNoRaw($message); } @@ -147,7 +147,7 @@ public function testExposedFilter() { $users = array_map('strtolower', $users); $options['query']['uid'] = implode(', ', $users); $this->drupalGet($path, $options); - $message = \Drupal::translation()->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); + $message = $this->container->get('string_translation')->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); $this->assertRaw($message); // Pass in an invalid username and a valid username. @@ -157,7 +157,7 @@ public function testExposedFilter() { $users = array($users[0]); $this->drupalGet($path, $options); - $message = \Drupal::translation()->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); + $message = $this->container->get('string_translation')->formatPlural(count($users), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', $users))); $this->assertRaw($message); // Pass in just valid usernames.