W3cubDocs

/Drupal 8

protected function 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 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StringTranslation!PluralTranslatableMarkup.php/function/PluralTranslatableMarkup::getPluralIndex/8.1.x