diff -u b/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php --- b/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -35,32 +35,2 @@ * {@inheritdoc} - * - * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use - * \Drupal\Core\Validation\DrupalTranslator::trans() instead. - * - * @see https://www.drupal.org/node/3255250 - */ - public function transChoice($id, $number, array $parameters = [], $domain = NULL, $locale = NULL) { - @trigger_error(__NAMESPACE__ . '\DrupalTranslator::transChoice() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use DrupalTranslator::trans() instead. See https://www.drupal.org/node/3255250', E_USER_DEPRECATED); - // Violation messages can separated singular and plural versions by "|". - $ids = explode('|', $id); - - if (!isset($ids[1])) { - throw new \InvalidArgumentException(sprintf('The message "%s" cannot be pluralized, because it is missing a plural (e.g. "There is one apple|There are @count apples").', $id)); - } - - // Normally, calls to formatPlural() need to use literal strings, like - // formatPlural($count, '1 item', '@count items') - // so that the Drupal project POTX string extractor will correctly - // extract the strings for translation and save them in a format that - // formatPlural() can work with. However, this is a special case, because - // Drupal is supporting a constraint message format from Symfony. So - // although $id looks like a variable here, it is actually coming from a - // static string in a constraint class that the POTX extractor knows about - // and has processed to work with formatPlural(), so this specific call to - // formatPlural() will work correctly. - return \Drupal::translation()->formatPlural($number, $ids[0], $ids[1], $this->processParameters($parameters), $this->getOptions($domain, $locale)); - } - - /** - * {@inheritdoc} */ only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Validation/DrupalTranslatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Validation/DrupalTranslatorTest.php @@ -5,7 +5,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\Core\StringTranslation\TranslationManager; -use Drupal\Core\Validation\DrupalTranslator; use Drupal\Tests\UnitTestCase; /** @@ -43,19 +42,4 @@ public function setUp(): void { \Drupal::setContainer($container); } - /** - * Test transChoice deprecation message. - * - * @covers ::transChoice - * @group legacy - */ - public function testDeprecation() { - $this->expectDeprecation('Drupal\Core\Validation\DrupalTranslator::transChoice() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use DrupalTranslator::trans() instead. See https://www.drupal.org/node/3255250'); - $translator = new DrupalTranslator(); - $this->assertInstanceOf( - PluralTranslatableMarkup::class, - $translator->transChoice('There is one apple | There are @count apples', 1) - ); - } - }