public static function PluralTranslatableMarkup::createFromTranslatedString in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php \Drupal\Core\StringTranslation\PluralTranslatableMarkup::createFromTranslatedString()
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\Render\FormattableMarkup. 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
static A PluralTranslatableMarkup object.
2 calls to PluralTranslatableMarkup::createFromTranslatedString()
- LocalePluralFormatTest::testGetPluralFormat in core/
modules/ locale/ tests/ src/ Functional/ LocalePluralFormatTest.php - Tests locale_get_plural() and \Drupal::translation()->formatPlural() functionality.
- NumericField::render in core/
modules/ views/ src/ Plugin/ views/ field/ NumericField.php - Renders the field.
File
- core/
lib/ Drupal/ Core/ StringTranslation/ PluralTranslatableMarkup.php, line 98
Class
- PluralTranslatableMarkup
- A class to hold plural translatable markup.
Namespace
Drupal\Core\StringTranslationCode
public static function createFromTranslatedString($count, $translated_string, array $args = [], array $options = []) {
$plural = new static($count, '', '', $args, $options);
$plural->translatedString = $translated_string;
return $plural;
}