WP_Translation_File::make_plural_form_function
Makes a function, which will return the right translation index, according to the plural forms header.
Method of the class: WP_Translation_File{}
No Hooks.
Returns
callable(Int. $num): int Plural forms function.
Usage
// protected - for code of main (parent) or child class $result = $this->make_plural_form_function( $expression ): callable;
- $expression(string) (required)
- Plural form expression.
Changelog
| Since 6.5.0 | Introduced. |
WP_Translation_File::make_plural_form_function() WP Translation File::make plural form function code WP 6.9
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' );
}
}