public function DrupalTranslator::trans

public DrupalTranslator::trans($id, array $parameters = array(), $domain = NULL, $locale = NULL)

Translates the given message.

Parameters

string $id The message id (may also be an object that can be cast to string):

array $parameters An array of parameters for the message:

string|null $domain The domain for the message or null to use the default:

string|null $locale The locale or null to use the default:

Return value

string The translated string

Throws

\InvalidArgumentException If the locale contains invalid characters

Overrides TranslatorInterface::trans

File

core/lib/Drupal/Core/Validation/DrupalTranslator.php, line 25

Class

DrupalTranslator
Translates strings using Drupal's translation system.

Namespace

Drupal\Core\Validation

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Validation!DrupalTranslator.php/function/DrupalTranslator::trans/8.1.x