8.3.x StringTranslationTrait.php protected StringTranslationTrait::getNumberOfPlurals($langcode = NULL)
8.0.x StringTranslationTrait.php protected StringTranslationTrait::getNumberOfPlurals($langcode = NULL)
8.1.x StringTranslationTrait.php protected StringTranslationTrait::getNumberOfPlurals($langcode = NULL)
8.2.x StringTranslationTrait.php protected StringTranslationTrait::getNumberOfPlurals($langcode = NULL)
8.4.x StringTranslationTrait.php protected StringTranslationTrait::getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

See also

\Drupal\locale\PluralFormulaInterface::getNumberOfPlurals()

4 calls to StringTranslationTrait::getNumberOfPlurals()
NumericField::buildOptionsForm in core/modules/views/src/Plugin/views/field/NumericField.php
Default options form that provides the label widget that all fields should have.
PluralVariants::getSourceElement in core/modules/config_translation/src/FormElement/PluralVariants.php
Returns the source element for a given configuration definition.
PluralVariants::getTranslationElement in core/modules/config_translation/src/FormElement/PluralVariants.php
Returns the translation form element for a given configuration definition.
TranslateEditForm::buildForm in core/modules/locale/src/Form/TranslateEditForm.php
Form constructor.

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