I am working with a site that is running WordPress in English, but they would like to run one of their plugins using the Welsh language. We already have the appropriate .po/.mo files for the plugin, but they are not being used while WordPress is running in English. Is there any way, perhaps with some custom PHP code in the plugin, that we can force WordPress to use the Welsh language files just for this plugin, but leave the rest of the site in English?

  • That may depend on the plugin. Can you tell us which plugin it is and possibly provide a link or some sample code of what you have tried so far?
    – GhostToast
    Commented Jun 5, 2013 at 15:11

2 Answers 2


Assuming the plugin makes use of localization at all, you could for example try exchanging the possible load_plugin_textdomain call with load_textdomain where you can point to the file you like.

A cleaner way would be using the plugin_locale filter that let's you modify the locale used by a plugin:

function my_plugin_locale_filter($locale, $domain)
    if($domain === 'the_plugins_textdomain')
        return 'cy_CY';

    return $locale;
add_filter('plugin_locale', 'my_plugin_locale_filter', 10, 2);

That way the plugin can more or less safely be updated without the custom code being overwritten.

// to force use English, this filter value must return true.
add_filter('override_load_textdomain', 'myPlugin_OverrideLoadTextDomain', 10, 3);

add_filter('plugin_locale', 'myPlugin_forceUseLanguageForCertainPlugin', 10, 2);

function myPlugin_OverrideLoadTextDomain($override, $domain, $mofile) {
    if ($domain === 'woocommerce') {// change text domain from woocommerce to what you want.
        $override = true;

    return $override;

function myPlugin_forceUseLanguageForCertainPlugin($locale, $domain) {
    if ($domain ==== 'woocommerce') {// change text domain from woocommerce to what you want.
        $locale = 'en_US';// change your locale here to whatever you want.

    return $locale;

It required 2 filter hooks to work.

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.