PluralTranslatableMarkup::__construct

public PluralTranslatableMarkup::__construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL)

Constructs a new PluralTranslatableMarkup object.

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

Parameters

int $count: The item count to display.

string $singular: The string for the singular case. Make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use @count in the singular string.

string $plural: The string for the plural case. Make sure it is clear this is plural, to ease translation. Use @count in place of the item count, as in "@count new comments".

array $args: (optional) An array with placeholder replacements, keyed by placeholder. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for additional information about placeholders. Note that you do not need to include @count in this array; this replacement is done automatically for the plural cases.

array $options: (optional) An associative array of additional options. See t() for allowed keys.

\Drupal\Core\StringTranslation\TranslationInterface $string_translation: (optional) The string translation service.

Overrides TranslatableMarkup::__construct

See also

\Drupal\Component\Render\FormattableMarkup::placeholderFormat()

File

core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 63

Class

PluralTranslatableMarkup
A class to hold plural translatable markup.

Namespace

Drupal\Core\StringTranslation

Code

public function __construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL) {
  $this->count = $count;
  $translatable_string = implode(static::DELIMITER, array($singular, $plural));
  parent::__construct($translatable_string, $args, $options, $string_translation);
}
doc_Drupal
2016-10-29 09:34:19
Comments
Leave a Comment

Please login to continue.