You are here

function _search_api_drush_format_plural in Search API 7

Copy of formal_plural that works with drush as 't' may not be available.

2 string references to '_search_api_drush_format_plural'
_search_api_batch_indexing_callback in ./search_api.module
Batch API callback for the indexing functionality.
_search_api_batch_indexing_finished in ./search_api.module
Batch API finishing callback for the indexing functionality.

File

./search_api.drush.inc, line 431
Drush commands for SearchAPI.

Code

function _search_api_drush_format_plural($count, $singular, $plural, array $args = array(), array $options = array()) {
  $args['@count'] = $count;
  if ($count == 1) {
    return dt($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 dt($plural, $args, $options);
  }
  else {
    switch ($index) {
      case "0":
        return dt($singular, $args, $options);
      case "1":
        return dt($plural, $args, $options);
      default:
        unset($args['@count']);
        $args['@count[' . $index . ']'] = $count;
        return dt(strtr($plural, array(
          '@count' => '@count[' . $index . ']',
        )), $args, $options);
    }
  }
}