W3cubDocs

/WordPress

Gettext_Translations::make_plural_form_function( int $nplurals, string $expression ): callable

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

Parameters

$npluralsintrequired
$expressionstringrequired

Return

callable

Source

public function make_plural_form_function( $nplurals, $expression ) {
	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( 2, 'n != 1' );
	}
}

Changelog

Version Description
2.8.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/gettext_translations/make_plural_form_function