Make WordPress Core

Opened 5 hours ago

Closed 81 minutes ago

#62547 closed defect (bug) (worksforme)

Notice for _load_textdomain_just_in_time despite correct use of init hook

Reported by: markhowellsmead's profile markhowellsmead Owned by: swissspidy's profile swissspidy
Milestone: Priority: normal
Severity: normal Version: trunk
Component: I18N Keywords:
Focuses: Cc:

Description

The notice “Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pt-must-use domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later.” is being thrown in a private plugin. The call to load_plugin_text_domain is as follows.

function ptMustUseTranslations()
{
	load_plugin_textdomain('pt-must-use', false, __DIR__ . '/languages');
}
add_action('init', 'ptMustUseTranslations');

Change History (1)

#1 @swissspidy
81 minutes ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from assigned to closed

This code alone does not trigger this notice.

You are probably calling __() somewhere else in your mu-plugin earlier than init. As per https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/, tools like Query Monitor are a snippet like the following one can help you pinpoint the exact location:

add_action(
	'doing_it_wrong_run',
	static function ( $function_name ) {
		if ( '_load_textdomain_just_in_time' === $function_name ) {
			debug_print_backtrace();
		}
	}
);
Note: See TracTickets for help on using tickets.