Translation::__construct

public Translation::__construct(array $values)

Constructs a new class instance.

Parses values passed into this class through the t() function in Drupal and handles an optional context for the string.

Parameters

array $values: Possible array keys:

  • value (required): the string that is to be translated.
  • arguments (optional): an array with placeholder replacements, keyed by placeholder.
  • context (optional): a string that describes the context of "value";

File

core/lib/Drupal/Core/Annotation/Translation.php, line 75

Class

Translation
Defines a translatable annotation object.

Namespace

Drupal\Core\Annotation

Code

public function __construct(array $values) {
  $string = $values['value'];
  $arguments = isset($values['arguments']) ? $values['arguments'] : array();
  $options = array();
  if (!empty($values['context'])) {
    $options = array(
      'context' => $values['context'],
    );
  }
  $this->translation = new TranslatableMarkup($string, $arguments, $options);
}
doc_Drupal
2016-10-29 09:49:14
Comments
Leave a Comment

Please login to continue.