Using plural-only translation of register_post_status() in plugin

// Get the plural post status label
$ps_status_label = $status->label_count;

$submenu[$menu][] = array(

  sprintf(
    translate_nooped_plural(
      $ps_status_label,
      $ps_status_count
    ),
    $ps_status_count
  ),

This should work as expected for the core translations. Now you need the textdomain, so lets search for the string you wish to translate

foreach ( $GLOBALS['l10n'] as $domain => $data ) {
    if ( in_array( $ps_status_label[0], array_keys( $data->entries ) ) )
        break;

    $domain = '';
}

$domain = ( ! empty( $domain ) ) ? $domain : 'default';

And now you can alter the first code snippet to

// Get the plural post status label
$ps_status_label = $status->label_count;

$submenu[$menu][] = array(

  sprintf(
    translate_nooped_plural(
      $ps_status_label,
      $ps_status_count,
      $domain
    ),
    $ps_status_count
  ),

You only need the plural form of the post status, just rise the count value in translate_nooped_plural()

sprintf(
  translate_nooped_plural(
    $ps_status_label,
    10,
    $domain
  ),
  $ps_status_count
),

This will always return the plural form because the count value is greater than 1. Be sure to use a value graeter than 3, because in some languages there are differences between the cases for one, two or more.

Just to clearify:

translate_nooped_plural(
  [array(
    [string for singular]
    [string for plural]
  ),
  [count] (1 = select singular string, greater than 1 select the plural string)
  [domain]
)

Leave a Comment