How to use Yoast SEO backend in english even if WPLANG variable is not english?

I added this code to my functions.php file

add_filter('locale', 'wpse27056_setLocale');
function wpse27056_setLocale($locale) {
    if ( is_admin() ) {
        return 'en_US';
    }

    return $locale;
}

so the frontend is available in ro_RO and wp-admin is available in en_US

Read More

Well… that almost worked excepting Yoast’s WordPress SEO plugin which is translated in romanian.

What can i do with that plugin to be displayed in english?

Related posts

Leave a Reply

2 comments

  1. That plugin loads its language the moment its main file is included:

    load_plugin_textdomain( 'wordpress-seo', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    

    So when your locale filter is used, the language is already there. :/

    Move your small plugin into the mu-plugins directory. You can create it if it doesn’t exists in wp-content. That should load your plugin earlier than Yoast’s.

    Lesson: Never load your language files before wp_loaded.

  2. There is even a better solution: a filter called plugin_locale. It filters the locale argument before using it in load_plugin_textdomain.

    add_filter( 'plugin_locale', 'mytheme_plugin_locale' );
    
    function mytheme_plugin_locale() {
        return 'en_US';
    }