load_plugin_text_domain() never works

Question

This code never works:

function i18n_load_plugin_textdomain() {
    $path = '[DIR]/wp-content/plugins/my-plugin/languages/my-plugin-de_DE.mo';     
    load_plugin_textdomain( 'my-plugin', false, $path);
}
add_action('plugins_loaded', 'i18n_load_plugin_textdomain');

I also tried ‘init’ instead of ‘plugins_loaded’ hook.

I tested $path with this different values (strings!) – no one worked. load_plugin_textdomain() returned always false.

$path = '[URL]/wp-content/plugins/my-plugin/languages/my-plugin-de_DE.mo';
$path = '[DIR]wp-contentpluginsmy-plugin/languages/my-plugin-de_DE.mo';
$path = 'languages/my-plugin-de_DE.mo';
$path = '/languages/my-plugin-de_DE.mo';
$path = '/languages/';
$path = '/languages';
$path = 'languages';
$path = '/';
$path = '';

But this works:

function i18n_load_textdomain() {
    $mofile = '[DIR]/wp-content/plugins/my-plugin/languages/my-plugin-de_DE.mo';
    load_textdomain( 'my-plugin', $mofile);
}
add_action('plugins_loaded', 'i18n_load_textdomain');

Can anyone tell me WHY?

0
Tom 4 months 0 Answers 11 views 0

Leave an answer