i've just built my first plugin for wp, and even if it's not a great "code poetry" ;) it works as it should. It's a plugin that transform the default wp gallery using the GalleryView 3.0 jquery plugin (http://spaceforaname.com/galleryview).

The only thing i'm not able to do is localization. Localization for this plugin in means translating the admin interface, where someone can configure the jquery plugin options to change the aspect of the resulting gallery.

I've tried to follow the millions of tutorials present on the web, read a lot of posts about this issue on forums and followed the guidelinees of codex... but still with no luck.

This is what i've done:

  1. Every text line is inside a gettext function ( __ and _e )
  2. Using poedit i created the .po and .mo file scanning the plugin directory (everythig went ok), then i added translations on that file.
  3. I named the .po file like that NAME-OF-THE-PLUGIN-it_IT.po (the .mo file was generated with the same name)
  4. I've put the translations files inside the plugin folder /languages (name of the folder is the same of the plugin and of the translations files)
  5. Then i've tried to add the load_plugin_textdomain function inside the main plugin file. I've tried because there's no way to get it working.

The only thing on which i'm not sure is the fact that the plugin i've created is not under a class + constructor funcions... just because i'm still not so good in coding.

I've put the load_plugin_textdomain inside an add_action on init, like this:

add_action('init', 'gw_load_translation_file');

function gw_load_translation_file() {
    // relative path to WP_PLUGIN_DIR where the translation files will sit:
    $plugin_path = dirname(plugin_basename( __FILE__ ) .'/languages' );
    load_plugin_textdomain( 'gallery-view-for-wordpress', false, $plugin_path );

The lines above are not inside a logic, they are just in the main plugin file, like that.

This is an example of my use of gettext functions:

<h3><?php _e('Panel Options', 'gallery-view-for-wordpress') ?></h3>

What did i not understand?

  • 1
    What are you expecting to happen, unless you're running your installation in another language/locale you're not going to see anything getting translated. Perhaps my translatable plugin might be of use to you for testing locale changes.
    – t31os
    Mar 23, 2011 at 11:43
  • can you describe what's going wrong? Is it just that nothing is being translated? If so, do you have more than one language set up? (It sounds like you might, but it's not clear from the question). If not, are there any errors? Is WP_DEBUG set to true in your wp-config.php? That might help shed light on things. Mar 23, 2011 at 23:07
  • @t31os I'm obviously running an Italian version of WP. (i've already looked at your nice translatable plugin, but to use it i shoudl actually start again my plugin because I do not use classes)
    – bluantinoo
    Mar 25, 2011 at 15:55
  • @Gavin Anderegg my problem is that just my plugin oprions page is not translated. So the problem must be in my plugin. I've tried to set WP_DEBUG to true, but i have no errors related to my scripts. I have just this advice on front end (i'm using basic twentyten template): Notice: register_uninstall_hook was called incorrectly. Only a static class method or function can be used in an uninstall hook. (This message was added in version 3.1.) in D:\[...]\wp-includes\functions.php on line 3422 And a lot of others advices of deprecated funcions in admin, but nothing pointing at my scripts :(
    – bluantinoo
    Mar 25, 2011 at 15:56

1 Answer 1


$plugin_path = dirname( plugin_basename( __FILE__ ) ) . '/languages/';

  • adding the last slash does not change: nothing seems to be translated
    – bluantinoo
    Mar 25, 2011 at 15:53
  • I'm not just adding the trailing slash. Just replace (copy paste) the line with what I wrote above.
    – zeo
    Mar 25, 2011 at 19:04
  • you're right, i've tried... but it does not work :(((
    – bluantinoo
    Mar 26, 2011 at 13:19
  • Odd, because that will fix your plugin path. Originally it was wrong. Can you upload your latest work so that I can download.
    – zeo
    Mar 26, 2011 at 13:21
  • Why do you comment line 47? add_action('init', 'gw_load_translation_file'); Uncomment it.
    – zeo
    Mar 26, 2011 at 16:00

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.