Gettext_Translations::make_plural_form_function() WordPress Method

The Gettext_Translations::make_plural_form_function() Wordpress method is used to create a function that can be used to pluralize a word based on the number it is associated with. This is useful when creating translations for a website or application.

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

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


Parameters

$nplurals

(int)(Required)

$expression

(string)(Required)


Top ↑

Source

File: wp-includes/pomo/translations.php

		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' );
			}
		}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.