This page redirects to an external site: https://developer.wordpress.org/reference/hooks/gettext_with_context/
This filter hook is applied to the translated text by context-specific localization functions such as such as _x(). The filter is always applied even if localization is not in effect, and if the text domain has not been loaded.
For context-unspecific translation functions such as __(), see filter hook gettext.
Filter function arguments are: 'translated text', 'untranslated text', 'context, and 'text domain'.
apply_filters( 'gettext_with_context', $translated, $text, $context, $domain );
The text domain for WordPress translatable texts is 'default'.
/** * @param string $translated * @param string $text * @param string $context * @param string $domain * @return string */ function example_gettext_with_context( $translated, $text, $context, $domain ) { if ( 'example-plugin' == $domain ) { if ( 'directions' == $text && 'directions on map' == $context ) { $translated = 'map directions'; // not recipe instructions! } } return $translated; } add_filter( 'gettext_with_context', 'example_gettext_with_context', 10, 4 );