function TranslationManager::getPluralIndex

Same name in this branch
  1. 11.x core/modules/locale/src/TranslationManager.php \Drupal\locale\TranslationManager::getPluralIndex()
Same name and namespace in other branches
  1. main core/modules/locale/src/TranslationManager.php \Drupal\locale\TranslationManager::getPluralIndex()
  2. main core/lib/Drupal/Core/StringTranslation/TranslationManager.php \Drupal\Core\StringTranslation\TranslationManager::getPluralIndex()

Returns plural form index for a specific number.

The base implementation only distinguishes between singular and plural, so it always returns the second (index 1) plural form. Subclasses that know a language's full plural rules should override this method.

Parameters

int $count: Number to return plural for.

string|null $langcode: (optional) Language code to translate to a language other than what is used to display the page.

Return value

int The numeric index of the plural variant to use for this $langcode and $count combination.

1 call to TranslationManager::getPluralIndex()
TranslationManager::selectPluralForm in core/lib/Drupal/Core/StringTranslation/TranslationManager.php
1 method overrides TranslationManager::getPluralIndex()
TranslationManager::getPluralIndex in core/modules/locale/src/TranslationManager.php
Returns plural form index for a specific number.

File

core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 147

Class

TranslationManager
Defines a chained translation implementation combining multiple translators.

Namespace

Drupal\Core\StringTranslation

Code

protected function getPluralIndex(int $count, ?string $langcode = NULL) : int {
  return 1;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.