public static function PluralTranslatableMarkup::createFromTranslatedString

public static PluralTranslatableMarkup::createFromTranslatedString($count, $translated_string, array $args = [], array $options = [])

Constructs a new class instance from already translated markup.

This method ensures that the string is pluralized correctly. As opposed to the __construct() method, this method is designed to be invoked with a string already translated (such as with configuration translation).

Parameters

int $count: The item count to display.

string $translated_string: The already translated string.

array $args: An associative array of replacements to make after translation. Instances of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Utility\SafeMarkup::format(). Note that you do not need to include @count in this array; this replacement is done automatically for the plural cases.

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

Return value

\Drupal\Core\StringTranslation\PluralTranslatableMarkup A PluralTranslatableMarkup object.

File

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

Class

PluralTranslatableMarkup
A class to hold plural translatable markup.

Namespace

Drupal\Core\StringTranslation

Code

public static function createFromTranslatedString($count, $translated_string, array $args = [], array $options = []) {
  $plural = new static($count, '', '', $args, $options);
  $plural->translatedString = $translated_string;
  return $plural;
}

© 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::createFromTranslatedString/8.1.x