Di antara fungsi Drush yang memproses teks , tidak ada fungsi seperti itu, tetapi Anda dapat mengimplementasikannya menggunakan kode dari format_plural () , menggantikan semua panggilan t()
dengan panggilan dt()
.
function drush_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);
}
}
}