W3cubDocs

/Drupal 8

protected function StringTranslationTrait::getNumberOfPlurals

protected StringTranslationTrait::getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

See also

\Drupal\locale\PluralFormulaInterface::getNumberOfPlurals()

File

core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php, line 88

Class

StringTranslationTrait
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Namespace

Drupal\Core\StringTranslation

Code

protected function getNumberOfPlurals($langcode = NULL) {
  if (\Drupal::hasService('locale.plural.formula')) {
    return \Drupal::service('locale.plural.formula')->getNumberOfPlurals($langcode);
  }
  // We assume 2 plurals if Locale's services are not available.
  return 2;
}

© 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!StringTranslationTrait.php/function/StringTranslationTrait::getNumberOfPlurals/8.1.x