class PluralFormula implements PluralFormulaInterface (View source)

Manages the storage of plural formula per language in state.

Properties

protected LanguageManagerInterface $languageManager
protected StateInterface $state
protected array $formulae

The plural formula and count keyed by langcode.

Methods

__construct(LanguageManagerInterface $language_manager, StateInterface $state)

No description

setPluralFormula(string $langcode, int $plural_count, array $formula)

No description

int
getNumberOfPlurals(null|string $langcode = NULL)

Returns the number of plurals supported by a given language.

array
getFormula(string $langcode)

Gets the plural formula for a langcode.

array
loadFormulae()

Loads the formulae and stores them on the PluralFormula object if not set.

reset()

Resets the static formulae cache.

Details

__construct(LanguageManagerInterface $language_manager, StateInterface $state)

No description

Parameters

LanguageManagerInterface $language_manager

The language manager.

StateInterface $state

The state.

PluralFormulaInterface setPluralFormula(string $langcode, int $plural_count, array $formula)

No description

Parameters

string $langcode

The language code to get the formula for.

int $plural_count

The number of plural forms.

array $formula

An array of formulae.

Return Value

PluralFormulaInterface

The PluralFormula object.

int getNumberOfPlurals(null|string $langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

null|string $langcode

(optional) The language code. If not provided, the current language will be used.

Return Value

int

Number of plural variants supported by the given language.

array getFormula(string $langcode)

Gets the plural formula for a langcode.

Parameters

string $langcode

The language code to get the formula for.

Return Value

array

An array of formulae.

protected array loadFormulae()

Loads the formulae and stores them on the PluralFormula object if not set.

Return Value

array

PluralFormulaInterface reset()

Resets the static formulae cache.

Return Value

PluralFormulaInterface

The PluralFormula object.