Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#63335 closed defect (bug) (invalid)

load_plugin_textdomain not working anymore since wp 6.8

Reported by: canic's profile canic Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.8
Component: I18N Keywords: reporter-feedback
Focuses: Cc:

Description

Hey,

we have upgraded some of our sites, after 6.8 the page don't translate anymore correctly.

Its a Plugin, in the header we have
Text Domain: sw-immosuite

and in the init hook we call
load_plugin_textdomain( 'text-domain', false, dirname( plugin_basename( FILE ) ) . '/languages/' );

Anyone knows anything about it or has the same problem?

Change History (5)

#1 follow-up: @swissspidy
12 months ago

  • Keywords reporter-feedback added

I hope this is just example code, but if your text domain is sw-immosuite, then you should use that in the load_plugin_textdomain() call. Not 'text-domain'.

If you otherwise have a minimal reproducible example code, e.g. in a GitHub Gist or so, that would be helpful.

I also recommend reading https://make.wordpress.org/core/2025/03/12/i18n-improvements-6-8/ to learn more about changes in 6.8. Though preventing translations from loading wouldn't be an intentional change :-)

#2 in reply to: ↑ 1 ; follow-up: @canic
12 months ago

Hey,

thanks for your reply.

You're right, it's just example code.

I found out through WP Query Monitor that the .mo file is being loaded, but when I check the "Doing it Wrong" tab, I see one message from WP Core.
https://i.ibb.co/wZBjbh4h/Screenshot-2025-04-22-212655.png

It's strange, because even when I remove load_plugin_textdomain and rely on the header comment for loading the text domain, it still doesn't work.

Replying to swissspidy:

I hope this is just example code, but if your text domain is sw-immosuite, then you should use that in the load_plugin_textdomain() call. Not 'text-domain'.

If you otherwise have a minimal reproducible example code, e.g. in a GitHub Gist or so, that would be helpful.

I also recommend reading https://make.wordpress.org/core/2025/03/12/i18n-improvements-6-8/ to learn more about changes in 6.8. Though preventing translations from loading wouldn't be an intentional change :-)

#3 in reply to: ↑ 2 ; follow-up: @canic
12 months ago

Small update:
Found out when loading within "plugins_loaded" the language token get succesffully loaded.

When calling load_plugin_textdomain in the "init" action, the path doesn't get modified to plugins/path/languages.

Isn't init the right position to call load_plugin_textdomain? Or is it too late.

Replying to canic:

Hey,

thanks for your reply.

You're right, it's just example code.

I found out through WP Query Monitor that the .mo file is being loaded, but when I check the "Doing it Wrong" tab, I see one message from WP Core.
https://i.ibb.co/wZBjbh4h/Screenshot-2025-04-22-212655.png

It's strange, because even when I remove load_plugin_textdomain and rely on the header comment for loading the text domain, it still doesn't work.

Replying to swissspidy:

I hope this is just example code, but if your text domain is sw-immosuite, then you should use that in the load_plugin_textdomain() call. Not 'text-domain'.

If you otherwise have a minimal reproducible example code, e.g. in a GitHub Gist or so, that would be helpful.

I also recommend reading https://make.wordpress.org/core/2025/03/12/i18n-improvements-6-8/ to learn more about changes in 6.8. Though preventing translations from loading wouldn't be an intentional change :-)

#4 in reply to: ↑ 3 @canic
12 months ago

  • Resolution set to invalid
  • Status changed from new to closed

Final update: We're using ACF PRO, and it seems there's a bug in ACF when combining load_plugin_textdomain and register_block_type while using i18n in blocks. I'm now creating a bug report in the ACF community.

Thanks anyway!

Replying to canic:

Small update:
Found out when loading within "plugins_loaded" the language token get succesffully loaded.

When calling load_plugin_textdomain in the "init" action, the path doesn't get modified to plugins/path/languages.

Isn't init the right position to call load_plugin_textdomain? Or is it too late.

Replying to canic:

Hey,

thanks for your reply.

You're right, it's just example code.

I found out through WP Query Monitor that the .mo file is being loaded, but when I check the "Doing it Wrong" tab, I see one message from WP Core.
https://i.ibb.co/wZBjbh4h/Screenshot-2025-04-22-212655.png

It's strange, because even when I remove load_plugin_textdomain and rely on the header comment for loading the text domain, it still doesn't work.

Replying to swissspidy:

I hope this is just example code, but if your text domain is sw-immosuite, then you should use that in the load_plugin_textdomain() call. Not 'text-domain'.

If you otherwise have a minimal reproducible example code, e.g. in a GitHub Gist or so, that would be helpful.

I also recommend reading https://make.wordpress.org/core/2025/03/12/i18n-improvements-6-8/ to learn more about changes in 6.8. Though preventing translations from loading wouldn't be an intentional change :-)

#5 @swissspidy
12 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.