I would like to perform a single word replacement for one of my plugins.


#: subscribe-and-connect-template.php:210
msgid "Subscribe"
msgstr "Subscribe"


#: subscribe-and-connect-template.php:210
msgid "Subscribe"
msgstr ""

I have replicated wp-content\plugins\subscribe-and-connect\languages\subscribe-and-connect.pot and made my change.

Where is the best place to store this new file and how do I load it?

  • 1
    i would like to load it from my child theme Mar 11, 2016 at 8:45

1 Answer 1


It seems there is no easy way to do this as load_plugin_textdomain() won't work as expected when called from a child theme.

A generic workaround was developed by Marius Vetrici but I've found it to be incompatible with Polylang under some circumstances.

The most reliable solution I have found is explicitly loading the translation using the load_textdomain() function which is one level lower than load_plugin_textdomain():

load_textdomain( $textdomain, get_stylesheet_directory().'/languages/'.$textdomain.'-'.get_locale().'.mo' );

The above example implies that you will keep your translation file in the languages folder under your child theme folder, and that it will be named according to the textdomain-lang_COUNTRY.mo scheme (for example: someplugin-en_US.mo).

You will have to pay attention to where to call load_textdomain() from, so that the locale is already available, and your translation is loaded before or after other translations (depending on your needs). If you only want to add new string translations, the order in which the translations are loaded doesn't matter, but if you want to override an existing translation, make sure that yours is the one loaded first, as (according to the documentation), the translation which was loaded first will be preferred over the one that is loaded later. Translations are typically loaded on the init hook, but in case of Polylang, the pll_language_defined hook is to be used.

Note that it is always a .mo (Machine Object) file that the system actually uses. The .po (Portable Object) files are human readable and are compiled into .mo files on each save. The .pot file is a template for .po files.

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.