function PluralFormula::getNumberOfPlurals
Same name in other branches
- 8.9.x core/modules/locale/src/PluralFormula.php \Drupal\locale\PluralFormula::getNumberOfPlurals()
- 10 core/modules/locale/src/PluralFormula.php \Drupal\locale\PluralFormula::getNumberOfPlurals()
- 11.x core/modules/locale/src/PluralFormula.php \Drupal\locale\PluralFormula::getNumberOfPlurals()
Overrides PluralFormulaInterface::getNumberOfPlurals
File
-
core/
modules/ locale/ src/ PluralFormula.php, line 72
Class
- PluralFormula
- Manages the storage of plural formula per language in state.
Namespace
Drupal\localeCode
public function getNumberOfPlurals($langcode = NULL) {
// Ensure that the formulae are loaded.
$this->loadFormulae();
// Set the langcode to use.
$langcode = $langcode ?: $this->languageManager
->getCurrentLanguage()
->getId();
// We assume 2 plurals if there is no explicit information yet.
if (!isset($this->formulae[$langcode]['plurals'])) {
return 2;
}
return $this->formulae[$langcode]['plurals'];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.