Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#58035 new enhancement

Allow to short-circuit load_textdomain()

Reported by: ocean90's profile ocean90 Owned by:
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

load_textdomain() has a filter override_load_textdomain which only allows to return true to prevent further execution of the function.

This becomes an issue if the filter callback was not able to load the file. Returning true in this case is not an option because that will cause _load_textdomain_just_in_time() to return early and not falling back to translations provided by a theme/plugin. Returning false means that load_textdomain() does all the work again even we already know that the file doesn't exist.

For this I'm proposing a pre_load_textdomain filter which runs before the current override_load_textdomain filter. This will be consistent with the pre_load_script_translations filter in load_script_translations() for JavaScript translations.

The filter will be useful to plugins which can develop and test alternative loading/caching strategies for translations.

Change History (1)

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


2 months ago
#1

  • Keywords has-patch has-unit-tests added
Note: See TracTickets for help on using tickets.