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
if ( !function_exists( 'translate_nooped_plural' ) ) { require_once ABSPATH . WPINC . '/l10n.php'; } // Array with singular, plural, and context keys, usually the result of _n_noop() or _nx_noop(). $nooped_plural = array(); // Number of objects. $count = null; // Optional. 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'. $domain = 'default'; // NOTICE! Understand what this does before running. $result = translate_nooped_plural($nooped_plural, $count, $domain);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/l10n.php
- function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
- if ( $nooped_plural['domain'] )
- $domain = $nooped_plural['domain'];
- if ( $nooped_plural['context'] )
- return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
- else
- return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
- }