ngettext
Filters the singular or plural form of a string.
Usage
add_filter( 'ngettext', 'wp_kama_ngettext_filter', 10, 5 );
/**
* Function for `ngettext` filter-hook.
*
* @param string $translation Translated text.
* @param string $single The text to be used if the number is singular.
* @param string $plural The text to be used if the number is plural.
* @param int $number The number to compare against to use either the singular or plural form.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*
* @return string
*/
function wp_kama_ngettext_filter( $translation, $single, $plural, $number, $domain ){
// filter...
return $translation;
}
- $translation(string)
- Translated text.
- $single(string)
- The text to be used if the number is singular.
- $plural(string)
- The text to be used if the number is plural.
- $number(int)
- The number to compare against to use either the singular or plural form.
- $domain(string)
- Text domain. Unique identifier for retrieving translated strings.
Changelog
| Since 2.2.0 | Introduced. |
Where the hook is called
ngettext
wp-includes/l10n.php 498
$translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );