english/libraries/joomla/methods.php
/**
	 * Like JText::sprintf but tries to pluralise the string.
	 *
	 * Examples:
	 * <script>alert(Joomla.JText._('<?php echo JText::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED", 1, array("script"=>true));?>'));</script> will generate an alert message containing '1 plugin successfully disabled'
	 * <?php echo JText::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED", 1);?> it will generate a '1 plugin successfully disabled' string
	 *
	 * @param   string   $string  The format string.
	 * @param   integer  $n       The number of items
	 * @param   mixed             Mixed number of arguments for the sprintf function. The first should be an integer.
	 * @param   array             optional Array of option array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean) where
	 *                             -jsSafe is a boolean to generate a javascript safe string
	 *                             -interpretBackSlashes is a boolean to interpret backslashes \\->\, \n->new line, \t->tabulation
	 *                             -script is a boolean to indicate that the string will be push in the javascript language store
	 *
	 * @return  string  The translated strings or the key if 'script' is true in the array of options
	 * @since   11.1
	 */
Like JText::sprintf but tries to pluralise the string.
Examples:
 will generate an alert message containing '1 plugin successfully disabled'
 it will generate a '1 plugin successfully disabled' string



@return  string  The translated strings or the key if 'script' is true in the array of options
@since   11.1
Like JText :: sprintf but tries to pluralise the string . Examples : will generate an alert message containing ' 1 plugin successfully disabled ' it will generate a ' 1 plugin successfully disabled ' string @return string The translated strings or the key if ' script ' is true in the array of options @since 11 . 1
public static function plural($string, $n)
	{
		$lang = JFactory::getLanguage();
		$args = func_get_args();
		$count = count($args);
		if ($count > 1) {
			$found = false;
			$suffixes = $lang->getPluralSuffixes((int)$n);
			foreach ($suffixes as $suffix) {
				$key = $string.'_'.$suffix;
				if ($lang->hasKey($key)) {
					$found = true;
					break;
				}
			}
			if (!$found) {
				$key = $string;
			}
			if (is_array($args[$count-1])) {
				$args[0] = $lang->_($key, array_key_exists('jsSafe', $args[$count-1]) ? $args[$count-1]['jsSafe'] : false, array_key_exists('interpretBackSlashes', $args[$count-1]) ? $args[$count-1]['interpretBackSlashes'] : true);
				if (array_key_exists('script',$args[$count-1]) && $args[$count-1]['script']) {
					self::$strings[$key] = call_user_func_array('sprintf', $args);
					return $key;
				}
			}
			else {
				$args[0] = $lang->_($key);
			}
			return call_user_func_array('sprintf', $args);
		}
		elseif ($count > 0) {
			$args[0] = $lang->_($string);
			return call_user_func_array('sprintf', $args);
		}
		return '';
	}
public static function plural ( $ string , $ n ) { $ lang = JFactory :: getLanguage ( ) ; $ args = func_get_args ( ) ; $ count = count ( $ args ) ; if ( $ count > 1 ) { $ found = false ; $ suffixes = $ lang -> getPluralSuffixes ( ( int ) $ n ) ; foreach ( $ suffixes as $ suffix ) { $ key = $ string . '_' . $ suffix ; if ( $ lang -> hasKey ( $ key ) ) { $ found = true ; break ; } } if ( ! $ found ) { $ key = $ string ; } if ( is_array ( $ args [ $ count - 1 ] ) ) { $ args [ 0 ] = $ lang -> _ ( $ key , array_key_exists ( 'jsSafe' , $ args [ $ count - 1 ] ) ? $ args [ $ count - 1 ] [ 'jsSafe' ] : false , array_key_exists ( 'interpretBackSlashes' , $ args [ $ count - 1 ] ) ? $ args [ $ count - 1 ] [ 'interpretBackSlashes' ] : true ) ; if ( array_key_exists ( 'script' , $ args [ $ count - 1 ] ) && $ args [ $ count - 1 ] [ 'script' ] ) { self :: $ strings [ $ key ] = call_user_func_array ( 'sprintf' , $ args ) ; return $ key ; } } else { $ args [ 0 ] = $ lang -> _ ( $ key ) ; } return call_user_func_array ( 'sprintf' , $ args ) ; } elseif ( $ count > 0 ) { $ args [ 0 ] = $ lang -> _ ( $ string ) ; return call_user_func_array ( 'sprintf' , $ args ) ; } return '' ; }
Like JText::sprintf but tries to pluralise the string.
Like JText :: sprintf but tries to pluralise the string .
// Try the key from the language plural potential suffixes // Not found so revert to the original. // Default to the normal sprintf handling.