Make WordPress Core

Opened 7 months ago

Closed 4 months ago

Last modified 4 months ago

#57056 closed enhancement (fixed)

Pass $locale to override_load_textdomain filter

Reported by: ocean90's profile ocean90 Owned by: audrasjb's profile audrasjb
Milestone: 6.2 Priority: normal
Severity: normal Version: 6.1
Component: I18N Keywords: good-first-bug has-patch commit
Focuses: Cc:

Description

In [53874] the $locale parameter was added to load_textdomain() so it can be used to properly fill WP_Textdomain_Registry.
Since the $locale may not be the same value as determine_locale() returns (e.g. when filtered by plugin_locale in load_plugin_textdomain()) we should also pass the new parameter to the filter so custom file loading implementations are using the same locale as load_textdomain() got.

Change History (13)

This ticket was mentioned in PR #3600 on WordPress/wordpress-develop by @cadic.


7 months ago
#1

  • Keywords has-patch added; needs-patch removed

In [53874] the $locale parameter was added to load_textdomain() so it can be used to properly fill WP_Textdomain_Registry.

Since the $locale may not be the same value as determine_locale() returns (e.g. when filtered by plugin_locale in load_plugin_textdomain()) we should also pass the new parameter to the filter so custom file loading implementations are using the same locale as load_textdomain() got.

Trac ticket: https://core.trac.wordpress.org/ticket/57056

#2 @cadic
7 months ago

  • Keywords needs-testing added

Added a PR for this

#3 @JeffPaul
7 months ago

  • Milestone changed from Future Release to 6.2

Adding to 6.2 milestone as initial PR updated from some code review feedback, needs final testing before readying for commit.

#4 @costdev
6 months ago

  • Keywords changes-requested added

This ticket was mentioned in Slack in #core by costdev. View the logs.


4 months ago

@SergeyBiryukov commented on PR #3600:


4 months ago
#6

Would it make sense to move the locale detection earlier in the function, so that it's always passed as a string to the filter, instead of string|null?

if ( ! $locale ) {
	$locale = determine_locale();
}

@swissspidy commented on PR #3600:


4 months ago
#7

IIRC that get_locale() call is deliberately as late as possible to avoid too many calls for performsnce reasons.

#8 @costdev
4 months ago

  • Keywords changes-requested removed

This ticket was discussed during the recent bug scrub. As all feedback on the PR has been addressed, I'm removing the changes-requested keyword.

This ticket was mentioned in Slack in #core by costdev. View the logs.


4 months ago

#10 @costdev
4 months ago

  • Keywords commit added

This ticket was discussed during the bug scrub. As the patch only adds a new parameter to a filter, this should not need testing. Adding for commit consideration.

#11 @costdev
4 months ago

  • Keywords needs-testing removed

#12 @audrasjb
4 months ago

  • Owner set to audrasjb
  • Resolution set to fixed
  • Status changed from new to closed

In 55196:

I18N: Pass $locale parameter to override_load_textdomain filter.

In [53874] the $locale parameter was added to load_textdomain() so it can be used to properly fill WP_Textdomain_Registry. Since $locale may not be the same value as determine_locale() returns (e.g. when filtered by plugin_locale in load_plugin_textdomain()) this changeset also passes the $locale parameter to the filter so custom file loading implementations are using the same locale as load_textdomain() got.

Follow-up to [53874].

Props ocean90, cadic, SergeyBiryukov, swissspidy, costdev.
Fixes #57056.

Note: See TracTickets for help on using tickets.