public function Translation::__construct in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Annotation/Translation.php \Drupal\Core\Annotation\Translation::__construct()
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\AnnotationCode
public function __construct(array $values) {
$string = $values['value'];
$arguments = isset($values['arguments']) ? $values['arguments'] : [];
$options = [];
if (!empty($values['context'])) {
$options = [
'context' => $values['context'],
];
}
$this->translation = new TranslatableMarkup($string, $arguments, $options);
}