translate_nooped_plural

Translates and retrieves the singular or plural form of a string that's been registered with _n_noop() or _nx_noop().

Description

(string) translate_nooped_plural( (array) $nooped_plural, (number) $count, (string) $domain = 'default' ); 

Used when you want to use a translatable plural string once the number is known.

Example:

Returns (string)

Either $single or $plural translated text.

Parameters (3)

0. $nooped_plural (array)
Array with singular, plural, and context keys, usually the result of _n_noop() or _nx_noop().
1. $count (number)
Number of objects.
2. $domain — Optional. (string) => 'default'
Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains a text domain passed to _n_noop() or _nx_noop(), it will override this value. Default default..

Usage

  1. if ( !function_exists( 'translate_nooped_plural' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // Array with singular, plural, and context keys, usually the result of _n_noop() or _nx_noop(). 
  5. $nooped_plural = array(); 
  6.  
  7. // Number of objects. 
  8. $count = null; 
  9.  
  10. // Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains 
  11. // a text domain passed to _n_noop() or _nx_noop(), it will override this value. Default 'default'. 
  12. $domain = 'default'; 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = translate_nooped_plural($nooped_plural, $count, $domain); 
  16.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/l10n.php  
  1. function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) { 
  2. if ( $nooped_plural['domain'] ) 
  3. $domain = $nooped_plural['domain']; 
  4.  
  5. if ( $nooped_plural['context'] ) 
  6. return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); 
  7. else 
  8. return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );