How to reload wordpress textdomains at runtime

Question

I’m currently using this to reload my theme and plugin textdomain in order to send e-mails (admin move, in admin language) in the user language.

add_filter("theme_locale", array($this, "theme_locale"), 9999, 2);
add_filter("plugin_locale", array($this, "plugin_locale"), 9999, 2);
$this->load_textdomains();
remove_filter("theme_locale", array($this, "theme_locale"), 9999, 2);
remove_filter("plugin_locale", array($this, "plugin_locale"), 9999, 2);


public function load_textdomains() {
    if (function_exists("WC")) {
        WC()->load_plugin_textdomain();
    }
    if (class_exists("My_Plugin_Class")) {
        My_Plugin_Class::load_plugin_textdomain();
    }
    load_my_theme_textdomain();
}

And thats okay, works fine.
But in my e-mail, i translate things using WORDPRESS textdomain.

How can i reload wordpress default textdomain, at runtime, like this?
The one that is used when using __ function without domain parameter.

0
, , Rodrigo Butzke 2 years 2019-12-27T15:15:35-05:00 0 Answers 88 views 0

Leave an answer

Browse
Browse