WordPress – Quick and easy way to translate internationalised I18n text

The gettext WordPress filter can be used to translate internationalised I18n text – that is, __() or _e(), without using complicated PO and MO files. If you need to change the text for an _x() string you will need to use the gettext_with_context filter.

In this example we’re using the gettext filter to change the Gravity Forms ‘This field is required.’ string to lower-case ‘this field is required’.

To use, copy into your theme’s functions.php file below the opening <?php line

add_filter( 'gettext', 'itsg_translate_text', 20, 3 );
 function itsg_translate_text( $translated_text, $text, $domain ) {
 if ( "This field is required." == $translated_text )
 $translated_text = __( 'this field is required.');
 return $translated_text;