|
MediaWiki master
|
Plural. More...
Public Member Functions | |
| __construct (private readonly Provider $provider,) | |
| Initializes the Plural handler with the given language code and provider. | |
| process (float $count, array $forms) | |
| Selects and returns the pluralized text form based on a numeric count. | |
Plural.
The Plural class selects the correct text form based on a numeric count and language-specific pluralization rules from the Unicode CLDR. It processes a number along with an array of text options, returning the appropriately pluralized text.
Usage Example: echo $plural->process( 3, [ 'article', 'articles' ] );
Definition at line 27 of file Plural.php.
| Wikimedia\Leximorph\Handler\Plural::__construct | ( | private readonly Provider | $provider | ) |
Initializes the Plural handler with the given language code and provider.
| Provider | $provider | The provider instance to use. |
Definition at line 36 of file Plural.php.
| Wikimedia\Leximorph\Handler\Plural::process | ( | float | $count, |
| array | $forms ) |
Selects and returns the pluralized text form based on a numeric count.
This method evaluates the provided numeric count using language-specific pluralization rules derived from the Unicode CLDR. It then selects the appropriate text form from the provided array of alternatives, taking into account any explicit plural forms if specified.
| float | $count | The numeric count to evaluate. |
| string[] | $forms | An array of text forms for pluralization. |
Definition at line 54 of file Plural.php.