WP_Translation_File::get_plural_expression_from_header()protectedWP 6.5.0

Returns the plural forms expression as a tuple.

Method of the class: WP_Translation_File{}

No Hooks.

Return

String. Plural forms expression.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_plural_expression_from_header( $header ): string;
$header(string) (required)
Plural-Forms header string.

Changelog

Since 6.5.0 Introduced.

WP_Translation_File::get_plural_expression_from_header() code WP 6.7.1

protected function get_plural_expression_from_header( string $header ): string {
	if ( preg_match( '/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches ) ) {
		return trim( $matches[2] );
	}

	return 'n != 1';
}