Support » Alpha/Beta/RC » load_plugin_textdomain() in 4.6RC

  • Resolved leemon

    (@leemon)


    Hi!

    I’m testing 4.6RC in a dev site. A private plugin I developed is no longer loading its .mo files from the plugin’s language folder using the following code:

    add_action( 'plugins_loaded', 'my_plugins_loaded' );
    function my_plugins_loaded() {
        load_plugin_textdomain( 'domain', false, dirname( plugin_basename( __FILE__ ) ) .  '/languages' );
    }

    I had no issues in 4.5.3. The following ticket shows that 4.6 will load languages files differently:

    https://core.trac.wordpress.org/ticket/34114

    My question is, do I have to change the way I load the plugin’s .mo files, now? Any help would be appreciated.

    @ocean90

Viewing 10 replies - 1 through 10 (of 10 total)
  • Dion Hulse

    (@dd32)

    Lead Developer

    @leemon Is that the exact code you’re using? Are you using domain as the text domain or something else?

    No, I’m using ep as the text domain, which is also defined in the Text Domain entry in the plugin header.

    It’s weird. I have another private plugin which loads its .mo files the same way and it’s working in 4.6RC.

    More weirdness. The problematic plugin is loading its .mo files on the frontend, but not while in the admin.

    Apparently, one of the plugins I’m using, Polylang, is conflicting with the loading of the others plugins local .mo files.

    Calling the my_plugins_loaded function in the init hook instead of the plugins_loaded one fixed the problem.

    add_action( 'init', 'my_plugins_loaded' );
    function my_plugins_loaded() {
        load_plugin_textdomain( 'domain', false, dirname( plugin_basename( __FILE__ ) ) .  '/languages' );
    }
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    Which one problem did that solve? Also if it’s not loading in admin, try admin_init?

    Calling the load_plugin_textdomain in the init hook instead of the plugins_loaded hook solved the loading of local .mo files of plugins in the backend with Polylang enabled.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    Did it also help the backend NOT showing the translations?

    Note that this means that a theme can no longer unload_textdomain() and then load_plugin_textdomain() using a file anywhere else in the file system. As of 4.6 you must load the plugin translations using load_textdomain() instead. At least as far as I can tell.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘load_plugin_textdomain() in 4.6RC’ is closed to new replies.