W3cubDocs

/Drupal 8

public function 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);
}

© 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!StringTranslation!PluralTranslatableMarkup.php/function/PluralTranslatableMarkup::__construct/8.1.x