Returns the plural form for a given number.
Parameters
$number
intrequired- Count.
Source
public function get_plural_form( int $number ): int {
if ( ! $this->parsed ) {
$this->parse_file();
}
if ( null === $this->plural_forms && isset( $this->headers['plural-forms'] ) ) {
$expression = $this->get_plural_expression_from_header( $this->headers['plural-forms'] );
$this->plural_forms = $this->make_plural_form_function( $expression );
}
if ( is_callable( $this->plural_forms ) ) {
/**
* Plural form.
*
* @var int $result Plural form.
*/
$result = call_user_func( $this->plural_forms, $number );
return $result;
}
// Default plural form matches English, only "One" is considered singular.
return ( 1 === $number ? 0 : 1 );
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.