I have a wp plugin with the required .pot and .mo localization files. Everything works fine, if I change the wordpress language, the plugin language changes too. But some users has requested if I could make an option to change only the plugin language without changing wordpress.

Is there any function I could use to load a specific localization file regardless of the one loaded in wp?

  • You are probably going to have to provide more detail? Are you only needing to change the admin interface for the plugin? Does the plugin generate front end content?
    – s_ha_dum
    Nov 1, 2015 at 20:05

1 Answer 1


Use plugin_locale filter:

apply_filters( 'plugin_locale', $locale, $domain );

Change locale like this:

$my_plugin_domain = 'my_plugin_domain_name';
$override_locale = 'es-ES';
    function ($locale, $domain) use ($my_plugin_domain, $override_locale) {
        if($domain == $my_plugin_domain) {
            $locale =  $override_locale;
        return $locale;
    }, 10, 2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.