Locale changed but plugin still showing default language


I’m changing the locale using the locale filter. I’ve tried various methods; creating a plugin and hooking into filter, declaring locale filter hook in the functions.php file, and even as simply as defining my WPLANG constant; in all cases, only my theme .mo file is translated, not any of the plugins.

My custom theme .mo file loads the correct translations but not the plugins. I’m wondering why the plugins are not showing the appropriate .mo translations when locale is changed?

Here is what I have:

* Plugin Name: WM10 Locale Change
* Description: A custom function to change locale.

function wm10_change_locale($locale = '') {
    return "fr_FR";

add_filter('locale', 'wm10_change_locale', 10);

How can I have the plugins recognize the locale change and serve up the appropriate .mo translation file? Should it not be as simple as setting the WPLANG constant? I’ve tried everything and I can’t get the plugins to output .mo translations in my specified language.

The .mo files are there, I’ve tried even adding them to the /wp-content/languages/plugins/ directory named appropriated {PLUGIN_NAME}-{LANGUAGE_CODE}.mo but still no luck.

, , Michel Joanisse 8 years 2015-03-19T07:46:38-05:00 0 Answers 88 views 0

Leave an answer