Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StringTranslationTrait.php

function StringTranslationTrait::getNumberOfPlurals

Returns the number of plurals supported by a given language.

Return value

int The number of plurals supported.

See also

\Drupal\locale\PluralFormulaInterface::getNumberOfPlurals()

3 calls to StringTranslationTrait::getNumberOfPlurals()
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 94

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;
}
RSS feed
Powered by Drupal