I built a simple localization plugin to suit some specifications needed by my orgnanization. For each language there is a single .mo file that contains both the theme translations as the page content translations. The .mo files are located in myplugin/languages/en_US.mo. I'm trying to use these .mo files for all gettext calls however I cannot get them to work.

Here is the code I'm using to load the text domain:

echo get_locale(); // es_ES
$directory = dirname(plugin_basename(__FILE__)) . '/lang/';
load_plugin_textdomain('localization-v', false, $directory); 
  • Curiously from quick look I don't see why would theme version not work for plugin. Note that unless in your example if run verbatim your echo will run before text domain is really loaded and single underscore is wrong function.
    – Rarst
    Commented Mar 10, 2014 at 21:38

1 Answer 1


You are completely loading your language file wrong in your plugin, and your file naming is also wrong.

load_theme_textdomain('my_plugin', plugin_dir_path( __FILE__ ) . '/languages');

should be

load_plugin_textdomain('my_plugin', false, dirname(plugin_basename(__FILE__)) . '/lang/');

Also, your mo and po files should be named my_plugin-en_US.mo and my_plugin-en_US.po. Go have a look at this tutorial also, this will help you out a lot.

  • Damn, the naming PLUGINNAME-en_EN.mo was key to my issue. Thanks for that hint!
    – Max Power
    Commented Nov 13, 2022 at 18:56

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.