[wp-trac] [WordPress Trac] #58321: `_load_textdomain_just_in_time()` firing too often for en_US sites
WordPress Trac
noreply at wordpress.org
Mon May 15 20:04:15 UTC 2023
#58321: `_load_textdomain_just_in_time()` firing too often for en_US sites
--------------------------+----------------------------
Reporter: swissspidy | Owner: swissspidy
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future Release
Component: I18N | Version: 6.2
Severity: normal | Keywords: needs-patch
Focuses: performance |
--------------------------+----------------------------
`_load_textdomain_just_in_time` is supposed to run once on the first
translation call to see if translations need to be loaded.
This works great on a localized site. However, I found out now that this
doesn't work on a bare en_US site.
At first glance, things to improve:
1. In `WP_Textdomain_Registry`, change this `! empty()` check to an
`isset()` check, to distinguish between absent (`null`) and retrieved
values but missing translation files (`false`):
https://github.com/WordPress/wordpress-
develop/blob/f375b68447d392ca7c189ebfadb6b908931d3812/src/wp-includes
/class-wp-textdomain-registry.php#L100
This way, `_load_textdomain_just_in_time()` bails earlier
2. In `get_translations_for_domain()` (or maybe elsewhere), set `$l10n[
$domain ] = &$noop_translations;` so that `_load_textdomain_just_in_time`
is only called once.
Needs some testing with locale switching to see if that actually works.
Not sure if this is a regression from 6.2, 6.1, or even from 4.6.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58321>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list