WP_Translation_File::make_plural_form_function( string $expression ): callable(int

In this article

Makes a function, which will return the right translation index, according to the plural forms header.

Parameters

$expressionstringrequired
Plural form expression.

Return

callable(int $num): int Plural forms function.

Source

protected function make_plural_form_function( string $expression ): callable {
	try {
		$handler = new Plural_Forms( rtrim( $expression, ';' ) );
		return array( $handler, 'get' );
	} catch ( Exception $e ) {
		// Fall back to default plural-form function.
		return $this->make_plural_form_function( 'n != 1' );
	}
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.