Translations only load from `wp-content/languages/plugins` but not from the plugin’s languages folder


I translated my plugin and put all the files (my-plugin-de_DE_formal.po,, my-plugin.pot) in the wp-content/plugins/my-plugin/languages folder.

My plugins header says:

Text Domain: my-plugin
Domain Path: /languages

Inside my code I loaded the textdomain like that:

function mp__load_textdomain() {
    load_plugin_textdomain( 'my-plugin', false, 'my-plugin/languages' );
add_action( 'init', 'mp__load_textdomain' );

I also check the return value of load_plugin_textdomain and it says true.

But all my translations will not show up. But if I move the .po and .mo files to the global folder wp-content/languages/plugins it works just fine.

I want to keep the translation file inside my plugin folder but I‘m stuck and can‘t figure out why it doesn‘t work that way.

Mountain 1 year 2021-12-04T17:00:42-05:00 0 Answers 0 views 0

Leave an answer