[wp-polyglots] Plugin I18N

Ryan Boren ryan at boren.nu
Tue Apr 12 17:09:38 GMT 2005


On Tue, 2005-04-12 at 18:58 +0200, Stefano wrote:
> Who it works, if it works, the I18N of plugins?
> For theme if there is a .mo file in the theme directory it will be
> used for translating it.
> 
> But what for the plugins that are all inside a commond directory?
> 
> I'm asking that cause one of my translators is releasing a photoplugin
> and he would like to make it availible for L10N.

.mo files for plugins are searched for in wp-content/plugins.  If you're
plugin file lives directly in wp-content/plugins, here's what happens.

load_plugin_textdomain('my-plugin-domain');  //  Call this in the
plugin.

WP looks for my-plugin-domain-$locale.mo in wp-content-plugins where
$locale is the current locale.

This doesn't work well for plugins that live in their own subdirectory
of wp-content/plugins, however.  A workaround is to run
plugin_basename() on the __FILE__ of the plugin, run dirname() on that,
and pass "$dirname/my-plugin-domain" to load_plugin_textdomain().   This
will load the .mo file from the plugin's directory rather than
wp-content/plugins allowing all of the plugins file to be in one
directory.

Ryan



More information about the wp-polyglots mailing list