PluralTranslation

Defines an annotation object for strings that require plural forms. Note that the return values for both 'singular' and 'plural' keys needs to be passed to \Drupal\Core\StringTranslation\TranslationInterface::formatPlural(). For example, the annotation can look like this: label_count = @ PluralTranslation( singular = "@count item", plural = "@count items", context = "cart_items", ), Remove spaces after @ in your actual plugin - these are put into this sample code so that it is

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 trans

PluralTranslatableMarkup::render

public PluralTranslatableMarkup::render() Renders the object as a string. Return value string The translated string. Overrides TranslatableMarkup::render File core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 105 Class PluralTranslatableMarkup A class to hold plural translatable markup. Namespace Drupal\Core\StringTranslation Code public function render() { if (!$this->translatedString) { $this->translatedString = $this->getStringTranslation()-&g

PluralTranslatableMarkup::getPluralIndex

protected PluralTranslatableMarkup::getPluralIndex() Gets the plural index through the gettext formula. Return value int File core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 147 Class PluralTranslatableMarkup A class to hold plural translatable markup. Namespace Drupal\Core\StringTranslation Code protected function getPluralIndex() { // We have to test both if the function and the service exist since in // certain situations it is possible that locale cod

PluralTranslatableMarkup::DELIMITER

The delimiter used to split plural strings. This is the ETX (End of text) character and is used as a minimal means to separate singular and plural variants in source and translation text. It was found to be the most compatible delimiter for the supported databases. File core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 17 Class PluralTranslatableMarkup A class to hold plural translatable markup. Namespace Drupal\Core\StringTranslation Code const DELIMITER = "\03

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 alrea

PluralTranslatableMarkup::$translatedString

The already translated string. Type: string File core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 31 Class PluralTranslatableMarkup A class to hold plural translatable markup. Namespace Drupal\Core\StringTranslation Code protected $translatedString;

PluralTranslatableMarkup::$count

The item count to display. Type: int File core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 24 Class PluralTranslatableMarkup A class to hold plural translatable markup. Namespace Drupal\Core\StringTranslation Code protected $count;

PluralTranslatableMarkup

A class to hold plural translatable markup. Hierarchy class \Drupal\Component\Render\FormattableMarkup implements \Countable, MarkupInterfaceclass \Drupal\Core\StringTranslation\TranslatableMarkup uses ToStringTraitclass \Drupal\Core\StringTranslation\PluralTranslatableMarkup File core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php, line 8 Namespace Drupal\Core\StringTranslation Members Name Modifiers Type Description FormattableMarkup::$arguments protected

PluralFormulaInterface::setPluralFormula

public PluralFormulaInterface::setPluralFormula($langcode, $plural_count, array $formula) Parameters string $langcode: The language code to get the formula for. int $plural_count: The number of plural forms. array $formula: An array of formulae. Return value self The PluralFormula object. File core/modules/locale/src/PluralFormulaInterface.php, line 21 Class PluralFormulaInterface An interface for a service providing plural formulae. Namespace Drupal\locale Code public function setPl