Wednesday, January 4, 2023
HomeWordPress Developmenttranslation - Cannot load textual content area in a mu-plugin

translation – Cannot load textual content area in a mu-plugin


My plugin is in: /root/.../mu-plugins/my-plugin

In /root/.../mu-plugins/my-plugin/languages/ I’ve the next information:

  • my-domain.pot
  • my-domain-fr_CA.po
  • my-domain-fr_CA.mo

The strings I need to translate are setup as:

'title' => __('Choices', 'my-domain'),

I’ve the next code in the primary plugin file (my-plugin/my-plugin.php):

add_action( 'init', perform() {
    $plugin_rel_path = dirname( plugin_basename(__FILE__) ).'/languages/';

    load_muplugin_textdomain( 'my-domain', $plugin_rel_path );
} );

I’ve performed round and tried numerous issues recommended elsewhere, reminiscent of utilizing plugins_loaded, muplugins_loaded, however the consensus appears to say that this have to be loaded on the init hook.

When var_dumping $plugin_rel_path I get the worth “my-plugin/languages/” which appears to be what I would like because it must be a relative path from the MU plugin folder.

That being mentioned, it doesn’t matter what I strive, the strings by no means get translated.

I appear to know that the trailing slash is important however I’ve tried with out.

My area doesn’t match my plugin identify and I’ve thought of that this may very well be a problem however from what I am studying it should not be as you cross the area you need loaded to the perform. If somebody is aware of higher I might actually admire some clarifications. I’ve translated plugins earlier than, and whereas I discover it considerably unintuitive, it is all the time labored.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments