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;
}
doc_Drupal
2016-10-29 09:45:19
Comments
Leave a Comment

Please login to continue.