I am trying to load localization for my plugin.
There is directory called languages in my plugin folder with .po and .mo files inside of it.
I have the following code in the plugin main file:
<?php
function myplugin_lang_init() {
$domain = 'mydomain';
// The "plugin_locale" filter is also used in load_plugin_textdomain()
$locale = apply_filters('plugin_locale', get_locale(), $domain);
load_textdomain($domain, WP_LANG_DIR.'/plugins/'.$domain.'-'.$locale.'.mo');
load_plugin_textdomain($domain, FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
}
// myplugin_lang_init(); // That works
add_action('plugins_loaded', 'myplugin_lang_init'); // I don't know why but it doesn't work
That works only if I call myplugin_lang_init()
directly, but doest't work if I do add_action('plugins_loaded', 'myplugin_lang_init')
.
Exactly the same code always was working perfectly in other plugins I've ever developed.
Could you please have a look at it? Have I missed something?
Thanks in advance.