function PluralTranslatableMarkup::getPluralIndex
Same name in other branches
- 9 core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php \Drupal\Core\StringTranslation\PluralTranslatableMarkup::getPluralIndex()
- 8.9.x core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php \Drupal\Core\StringTranslation\PluralTranslatableMarkup::getPluralIndex()
- 11.x core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php \Drupal\Core\StringTranslation\PluralTranslatableMarkup::getPluralIndex()
Gets the plural index through the gettext formula.
Return value
int
1 call to PluralTranslatableMarkup::getPluralIndex()
- PluralTranslatableMarkup::render in core/
lib/ Drupal/ Core/ StringTranslation/ PluralTranslatableMarkup.php - Renders the object as a string.
File
-
core/
lib/ Drupal/ Core/ StringTranslation/ PluralTranslatableMarkup.php, line 127
Class
- PluralTranslatableMarkup
- A class to hold plural translatable markup.
Namespace
Drupal\Core\StringTranslationCode
protected function getPluralIndex() {
// We have to test both if the function and the service exist since in
// certain situations it is possible that locale code might be loaded but
// the service does not exist. For example, where the parent test site has
// locale installed but the child site does not.
// @todo Refactor in https://www.drupal.org/node/2660338 so this code does
// not depend on knowing that the Locale module exists.
if (function_exists('locale_get_plural') && \Drupal::hasService('locale.plural.formula')) {
return locale_get_plural($this->count, $this->getOption('langcode'));
}
return -1;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.