You are here

public function PluralFormula::setPluralFormula in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/src/PluralFormula.php \Drupal\locale\PluralFormula::setPluralFormula()
  2. 9 core/modules/locale/src/PluralFormula.php \Drupal\locale\PluralFormula::setPluralFormula()

File

core/modules/locale/src/PluralFormula.php, line 57

Class

PluralFormula
Manages the storage of plural formula per language in state.

Namespace

Drupal\locale

Code

public function setPluralFormula($langcode, $plural_count, array $formula) {

  // Ensure that the formulae are loaded.
  $this
    ->loadFormulae();
  $this->formulae[$langcode] = [
    'plurals' => $plural_count,
    'formula' => $formula,
  ];
  $this->state
    ->set('locale.translation.formulae', $this->formulae);
  return $this;
}