W3cubDocs

/WordPress

Gettext_Translations::nplurals_and_expression_from_header( string $header ): array{0:

Returns the nplurals and plural forms expression from the Plural-Forms header.

Parameters

$headerstringrequired

Return

array{0: int, 1: string}

Source

public function nplurals_and_expression_from_header( $header ) {
	if ( preg_match( '/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches ) ) {
		$nplurals   = (int) $matches[1];
		$expression = trim( $matches[2] );
		return array( $nplurals, $expression );
	} else {
		return array( 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/nplurals_and_expression_from_header