Wrong language used while sending email from a filter callback

I’m sending email to admin and user when they filled a certain form.

I’m using two different hooks then, one is this one:


And the second is


Both seem to fire and work as I want them to (they fire when expected). BUT, inside them I use i18n strings like so:

$subject = __(‘Registration completed’,’my_txt_domain’);
$message = __(‘Some longer text etc.etc.’, ‘my_txt_domain’);
mytheme_send_email($mail, $$subject ,$message);

mytheme_send_email() is just a wrapper for wp_mail() that adds some footer content with additional __() strings and that’s about it.

Now in functions.php I have registered a text domain as usual which seems to work since theme strings are properly translated:

// Localisation Support
function my_theme_load_theme_textdomain()

// must be called before load_theme_textdomain()
add_filter( ‘locale’, ‘my_theme_localized’ );
function my_theme_localized( $locale )
if(defined(‘WPLANG’)) { // this is set in wp-config.php (define(‘WPLANG’, ‘en_EN’);)
return WPLANG;
return $locale;

load_theme_textdomain(‘my_txt_domain’, get_template_directory() . ‘/languages’);
add_action( ‘after_setup_theme’, ‘my_theme_load_theme_textdomain’ );

I know text domain string should have dashes instead of underscores, but the whole theme has them now and everything else is working so I don’t think this is the issue.

So: how would I force the correct language in filters/actions?

Any help appreciated.

Read more here:: Wrong language used while sending email from a filter callback

Leave a Reply

Your email address will not be published. Required fields are marked *