[wp-trac] [WordPress Trac] #58546: Warn if _load_textdomain_just_in_time() is used before init
WordPress Trac
noreply at wordpress.org
Thu Jun 15 16:22:19 UTC 2023
#58546: Warn if _load_textdomain_just_in_time() is used before init
-------------------------+-----------------------------
Reporter: swissspidy | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version:
Severity: normal | Keywords: dev-feedback
Focuses: |
-------------------------+-----------------------------
Whenever a translation function like `__()` is used for the first time
with a specific domain, `_load_textdomain_just_in_time()` kicks in to load
the plugin's/theme's translations automatically.
This function calls `determine_locale()` to load the translations in the
current user's locale if available.
If the JIT loading happens before the current user is set, it will load
the translations in the wrong locale.
Such situations were previously reported in #43869 and #45235.
What if we issued a `doing_it_wrong` warning within
`_load_textdomain_just_in_time` for such cases? This would urge developers
to fix their code to run at the right time.
If a lot of plugins are currently doing it wrong though, that might cause
a lot of noise.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58546>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list