Filter hook 'ngettext_with_context_{$domain}'

in WP Core File wp-includes/l10n.php at line 574

View Source

ngettext_with_context_{$domain}

Filter Hook
Description
Filters the singular or plural form of a string with gettext context for a domain. The dynamic portion of the hook name, `$domain`, refers to the text domain.

Hook Information

File Location wp-includes/l10n.php View on GitHub
Hook Type Filter
Line Number 574

Hook Parameters

Type Name Description
string $translation Translated text.
string $single The text to be used if the number is singular.
string $plural The text to be used if the number is plural.
int $number The number to compare against to use either the singular or plural form.
string $context Context information for the translators.
string $domain Text domain. Unique identifier for retrieving translated strings.

Usage Examples

Basic Usage
<?php
// Hook into ngettext_with_context_{$domain}
add_filter('ngettext_with_context_{$domain}', 'my_custom_filter', 10, 6);

function my_custom_filter($translation, $single, $plural, $number, $context, $domain) {
    // Your custom filtering logic here
    return $translation;
}

Source Code Context

wp-includes/l10n.php:574 - How this hook is used in WordPress core
<?php
 569  	 * @param string $plural      The text to be used if the number is plural.
 570  	 * @param int    $number      The number to compare against to use either the singular or plural form.
 571  	 * @param string $context     Context information for the translators.
 572  	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
 573  	 */
 574  	$translation = apply_filters( "ngettext_with_context_{$domain}", $translation, $single, $plural, $number, $context, $domain );
 575  
 576  	return $translation;
 577  }
 578  
 579  /**

PHP Documentation

<?php
/**
	 * Filters the singular or plural form of a string with gettext context for a domain.
	 *
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
	 *
	 * @since 5.5.0
	 *
	 * @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 $context     Context information for the translators.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 6
  • File: wp-includes/l10n.php
Related Hooks

Related hooks will be displayed here in future updates.