processParameters example

protected $locale;

  /** * {@inheritdoc} */
  public function trans($id, array $parameters = []$domain = NULL, $locale = NULL) {
    // If a TranslatableMarkup object is passed in as $id, return it since the     // message has already been translated.     if ($id instanceof TranslatableMarkup) {
      return $id;
    }
    return new TranslatableMarkup($id$this->processParameters($parameters)$this->getOptions($domain$locale));
  }

  /** * {@inheritdoc} */
  public function transChoice($id$number, array $parameters = []$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));
    }
Home | Imprint | This part of the site doesn't use cookies.