[wp-hackers] load_plugin_textdomain()

Nikolay Bachiyski nb at nikolay.bg
Wed Jul 23 14:12:05 GMT 2008


On Wed, Jul 23, 2008 at 4:48 PM, Otto <otto at ottodestruct.com> wrote:
> What is the correct and forward compatible way to call
> load_plugin_textdomain() inside a plugin? Assume that I want the .mo
> files to be inside the plugin's own directory and not in a lang
> directory or some such thing.

load_plugin_textdomain('domain',
PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)),
dirname(plugin_basename(__FILE__)));

The second argument is the path to the MO file, relative to ABSPATH.
Since 2.6 the plugin dir can be changed, so we introduced a third
argument, which is the path, relative to the plugins directory (e.g.
wp-content/plugins). This argument is deprecated, but will work at
least until 2.7.

If both arguments are supplied, the third one takes precedence.

If your plugin doesn't have to be compatible with WordPress < 2.6, you
can leave false for the second argument, to save some typing.

Happy hacking,
Nikolay.


More information about the wp-hackers mailing list