Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PluralTranslatableMarkup.php

function 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.

1 call to PluralTranslatableMarkup::createFromTranslatedString()
NumericField::render in core/modules/views/src/Plugin/views/field/NumericField.php
Renders the field.

File

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

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;
}
RSS feed
Powered by Drupal