public function DrupalTranslator::transChoice

Implements \Symfony\Component\Translation\TranslatorInterface::transChoice().

Overrides TranslatorInterface::transChoice

File

drupal/core/lib/Drupal/Core/Validation/DrupalTranslator.php, line 38
Contains \Drupal\Core\Validation\DrupalTranslator.

Class

DrupalTranslator
Translates strings using Drupal's translation system.

Namespace

Drupal\Core\Validation

Code

public function transChoice($id, $number, array $parameters = array(), $domain = NULL, $locale = NULL) {

  // 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));
  }
  return format_plural($number, $ids[0], $ids[1], $this
    ->processParameters($parameters), $this
    ->getOptions($domain, $locale));
}