You are here

public function StringTranslation::formatPluralTranslated in Service Container 7

Same name and namespace in other branches
  1. 7.2 src/StringTranslation/StringTranslation.php \Drupal\service_container\StringTranslation\StringTranslation::formatPluralTranslated()

Formats an already translated string containing a count of items.

This function ensures that the string is pluralized correctly. As opposed to the formatPlural() 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 $translation: The string containing the translation of a singular/plural pair. It may contain any number of possible variants (depending on the language translated to) separated by the value of the LOCALE_PLURAL_DELIMITER constant.

array $args: Associative array of replacements to make in the 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. The 'context' key is not supported because the passed string is already translated. Use the 'langcode' key to ensure the proper plural logic is used.

Return value

string The correct substring for the given $count with $args replaced.

Overrides TranslationInterface::formatPluralTranslated

See also

self::formatPlural()

\Drupal\Component\Utility\SafeMarkup::format()

File

src/StringTranslation/StringTranslation.php, line 54
Contains \Drupal\service_container\StringTranslation\StringTranslation.

Class

StringTranslation
Provides a t() based string translation.

Namespace

Drupal\service_container\StringTranslation

Code

public function formatPluralTranslated($count, $translation, array $args = array(), array $options = array()) {
  throw new \BadMethodCallException('StringTranslation::formatPluralTranslated is not implemented.');
}