function format_plural


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 format_plural($count, $singular, $plural, array $args = array(), array $options = array())
cle7 format_plural($count, $singular, $plural, array $args = array(), array $options = array())
elmsmedia7 format_plural($count, $singular, $plural, array $args = array(), array $options = array())
icor7 format_plural($count, $singular, $plural, array $args = array(), array $options = array())
meedjum_blog7 format_plural($count, $singular, $plural, array $args = array(), array $options = array())
mooc7 format_plural($count, $singular, $plural, array $args = array(), array $options = array())

Formats a string containing a count of items.

This function ensures that the string is pluralized correctly. Since t() is called by this function, make sure not to pass already-localized strings to it.

For example:

  $output = format_plural($node->comment_count, '1 comment', '@count comments');

Example with additional replacements:

  $output = format_plural($update_count,
    'Changed the content type of 1 post from %old-type to %new-type.',
    'Changed the content type of @count posts from %old-type to %new-type.',
    array('%old-type' => $info->old_type, '%new-type' => $info->new_type));


$count: The item count to display.

$singular: The string for the singular case. Make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use @count in the singular string.

$plural: The string for the plural case. Make sure it is clear this is plural, to ease translation. Use @count in place of the item count, as in "@count new comments".

$args: An associative array of replacements to make after translation. Instances of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed. See format_string(). Note that you do not need to include @count in this array; this replacement is done automatically for the plural case.

$options: An associative array of additional options. See t() for allowed keys.

Return value

A translated string.

See also



Related topics

109 calls to format_plural()
advagg_admin_info_form in sites/all/modules/ulmus/advagg/
Form builder; Show info about advagg and advagg settings.
aggregator_view in modules/aggregator/
Displays the aggregator administration page.
backup_migrate_schedule::get_frequency_description in sites/all/modules/ulmus/backup_migrate/includes/
Format a frequency in human-readable form.
cis_service_activation_codes_form in sites/all/modules/elmsln_contrib/cis_connector/modules/cis_service_activation_codes/cis_service_activation_codes.module
Activation code entry block / form.
comment-wrapper.tpl.php in sites/all/themes/ulmus/corolla/templates/comment-wrapper.tpl.php

... See full list

4 string references to 'format_plural'
views_handler_field_math::render in sites/all/modules/ulmus/views/handlers/
views_handler_field_numeric::options_form in sites/all/modules/ulmus/views/handlers/
Default options form that provides the label widget that all fields should have.
views_handler_field_numeric::option_definition in sites/all/modules/ulmus/views/handlers/
Information about options for all kinds of purposes will be held here. @code 'option_name' => array(
views_handler_field_numeric::render in sites/all/modules/ulmus/views/handlers/
Render the field.


includes/, line 1805
Common functions that many Drupal modules will need to reference.


function format_plural($count, $singular, $plural, array $args = array(), array $options = array()) {
  $args['@count'] = $count;
  if ($count == 1) {
    return t($singular, $args, $options);

  // Get the plural index through the gettext formula.
  $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1;
  // If the index cannot be computed, use the plural as a fallback (which
  // allows for most flexiblity with the replaceable @count value).
  if ($index < 0) {
    return t($plural, $args, $options);
  else {
    switch ($index) {
      case "0":
        return t($singular, $args, $options);
      case "1":
        return t($plural, $args, $options);
        $args['@count[' . $index . ']'] = $count;
        return t(strtr($plural, array('@count' => '@count[' . $index . ']')), $args, $options);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.