Translations::select_plural_form() WordPress Method

The Translations::select_plural_form() method is used to select the appropriate form of a string for a given number. It is used internally by the __() and _n() functions. This method accepts two parameters: $count (int) – The number of items $forms (array) – An array of strings containing the different forms of the string. The first form is used for singular, the second for two items, the third for three items, and so on. This method returns the appropriate form of the string for the given number.

Translations::select_plural_form( int $count ) #

Given the number of items, returns the 0-based index of the plural form to use


Description

Here, in the base Translations class, the common logic for English is implemented: 0 if there is one element, 1 otherwise

This function should be overridden by the subclasses. For example MO/PO can derive the logic from their headers.


Top ↑

Parameters

$count

(int)(Required)number of items


Top ↑

Source

File: wp-includes/pomo/translations.php

		public function select_plural_form( $count ) {
			return 1 == $count ? 0 : 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.