#58035 closed enhancement (fixed)
Allow to short-circuit load_textdomain()
Reported by: | ocean90 | Owned by: | ocean90 |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | has-patch has-unit-tests commit needs-dev-note add-to-field-guide |
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 (6)
This ticket was mentioned in PR #4227 on WordPress/wordpress-develop by @ocean90.
22 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
19 months ago
- Keywords commit added
- Owner set to ocean90
- Status changed from new to assigned
@ocean90 @swissspidy Marking this ready for commit.
@swissspidy commented on PR #4227:
19 months ago
#4
Committed in https://core.trac.wordpress.org/changeset/55928
Trac ticket: https://core.trac.wordpress.org/ticket/58035