i18n: Account for load_*_textdomain() after JIT loading.
Some checks are pending
Coding Standards / PHP coding standards (push) Waiting to run
Coding Standards / JavaScript coding standards (push) Waiting to run
Coding Standards / Slack Notifications (push) Blocked by required conditions
Coding Standards / Failed workflow tasks (push) Blocked by required conditions
End-to-end Tests / Test with SCRIPT_DEBUG ${{ matrix.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }} (false) (push) Waiting to run
End-to-end Tests / Test with SCRIPT_DEBUG ${{ matrix.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }} (true) (push) Waiting to run
End-to-end Tests / Slack Notifications (push) Blocked by required conditions
End-to-end Tests / Failed workflow tasks (push) Blocked by required conditions
JavaScript Tests / QUnit Tests (push) Waiting to run
JavaScript Tests / Slack Notifications (push) Blocked by required conditions
JavaScript Tests / Failed workflow tasks (push) Blocked by required conditions
Performance Tests / Performance tests ${{ matrix.memcached && '(with memcached)' || '' }} (false) (push) Waiting to run
Performance Tests / Performance tests ${{ matrix.memcached && '(with memcached)' || '' }} (true) (push) Waiting to run
Performance Tests / Slack Notifications (push) Blocked by required conditions
Performance Tests / Failed workflow tasks (push) Blocked by required conditions
PHP Compatibility / Check PHP compatibility (push) Waiting to run
PHP Compatibility / Slack Notifications (push) Blocked by required conditions
PHP Compatibility / Failed workflow tasks (push) Blocked by required conditions
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 7.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 7.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 7.4, example.org:8889) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, false, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 7.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 7.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 7.4, example.org:8889) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, false, true, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, true, false, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 5.7, true, true, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 7.2, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 7.3, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 7.4, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 8.0, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 8.1, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 8.2, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 8.3, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, false, ubuntu-latest, 8.4, true, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 7.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 7.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.0, false, true, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 7.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 7.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, false, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 7.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 7.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 8.4, false, true, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, false, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, false, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, false, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, false, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, false, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, false, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, true, ubuntu-latest, 7.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, true, ubuntu-latest, 8.0, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, true, ubuntu-latest, 8.1, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, true, ubuntu-latest, 8.2, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, true, ubuntu-latest, 8.3, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mysql, 9.0, false, true, ubuntu-latest, 8.4, example.org) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, false, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.11, false, true, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, false, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.4, false, true, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, false, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 10.6, false, true, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, false, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 7.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 7.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 8.0) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 8.1) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 8.2) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 8.3) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, false, true, ubuntu-latest, 8.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, true, false, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / PHP ${{ matrix.php }} (mariadb, 11.2, true, true, ubuntu-latest, 7.4) (push) Waiting to run
PHPUnit Tests / Slack Notifications (push) Blocked by required conditions
PHPUnit Tests / Failed workflow tasks (push) Blocked by required conditions
Test Build Processes / Core running from ${{ matrix.directory }} (build, ubuntu-latest, ${{ github.event_name == 'pull_request' && true || '' }}, true) (push) Waiting to run
Test Build Processes / Core running from ${{ matrix.directory }} (build, windows-latest) (push) Waiting to run
Test Build Processes / Core running from ${{ matrix.directory }} (src, ubuntu-latest) (push) Waiting to run
Test Build Processes / Core running from ${{ matrix.directory }} (src, windows-latest) (push) Waiting to run
Test Build Processes / Core running from ${{ matrix.directory }} (build, macos-latest) (push) Waiting to run
Test Build Processes / Core running from ${{ matrix.directory }} (src, macos-latest) (push) Waiting to run
Test Build Processes / Gutenberg running from ${{ matrix.directory }} (build, ubuntu-latest) (push) Waiting to run
Test Build Processes / Gutenberg running from ${{ matrix.directory }} (build, windows-latest) (push) Waiting to run
Test Build Processes / Gutenberg running from ${{ matrix.directory }} (src, ubuntu-latest) (push) Waiting to run
Test Build Processes / Gutenberg running from ${{ matrix.directory }} (src, windows-latest) (push) Waiting to run
Test Build Processes / Gutenberg running from ${{ matrix.directory }} (build, macos-latest) (push) Waiting to run
Test Build Processes / Gutenberg running from ${{ matrix.directory }} (src, macos-latest) (push) Waiting to run
Test Build Processes / Slack Notifications (push) Blocked by required conditions
Test Build Processes / Failed workflow tasks (push) Blocked by required conditions

When `load_*_textdomain()` functions are called after WordPress has already attempted just-in-time loading of translations, nothing happens. 

This updates the related logic to retry translation loading when a custom path is set to ensure all translations are available.

Additionally, this also fixes cases where an `en_US.mo` file is provided with non-English strings to override the default language.

Follow up to [59157].

Props swissspidy, peterwilsoncc, desrosj, apermo, sergeybiryukov, wildworks, tigriweb, twvania, looswebstudio, stimul, audrasjb, finntown, bluantinoo, timwhitlock, albigdd.
See #62337.

git-svn-id: https://develop.svn.wordpress.org/trunk@59430 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2024-11-20 02:48:40 +00:00
parent 9b6229463b
commit 193f6eb26e
6 changed files with 77 additions and 7 deletions

View File

@ -153,6 +153,16 @@ class WP_Textdomain_Registry {
* @param string $path Language directory path.
*/
public function set_custom_path( $domain, $path ) {
// If just-in-time loading was triggered before, reset the entry so it can be tried again.
if ( isset( $this->all[ $domain ] ) ) {
$this->all[ $domain ] = array_filter( $this->all[ $domain ] );
}
if ( empty( $this->current[ $domain ] ) ) {
unset( $this->current[ $domain ] );
}
$this->custom_paths[ $domain ] = rtrim( $path, '/' );
}
@ -336,7 +346,7 @@ class WP_Textdomain_Registry {
* If no path is found for the given locale and a custom path has been set
* using load_plugin_textdomain/load_theme_textdomain, use that one.
*/
if ( 'en_US' !== $locale && isset( $this->custom_paths[ $domain ] ) ) {
if ( isset( $this->custom_paths[ $domain ] ) ) {
$fallback_location = rtrim( $this->custom_paths[ $domain ], '/' ) . '/';
$this->set( $domain, $locale, $fallback_location );
return $fallback_location;

View File

@ -985,6 +985,9 @@ function load_default_textdomain( $locale = null ) {
* @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
* @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism.
*
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
* @global array<string, WP_Translations|NOOP_Translations> $l10n An array of all currently loaded text domains.
*
* @param string $domain Unique identifier for retrieving translated strings
* @param string|false $deprecated Optional. Deprecated. Use the $plugin_rel_path parameter instead.
* Default false.
@ -994,7 +997,8 @@ function load_default_textdomain( $locale = null ) {
*/
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
/** @var array<string, WP_Translations|NOOP_Translations> $l10n */
global $wp_textdomain_registry, $l10n;
if ( ! is_string( $domain ) ) {
return false;
@ -1011,6 +1015,11 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
$wp_textdomain_registry->set_custom_path( $domain, $path );
// If just-in-time loading was triggered before, reset the entry so it can be tried again.
if ( isset( $l10n[ $domain ] ) && $l10n[ $domain ] instanceof NOOP_Translations ) {
unset( $l10n[ $domain ] );
}
return true;
}
@ -1022,6 +1031,7 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
* @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism.
*
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
* @global array<string, WP_Translations|NOOP_Translations> $l10n An array of all currently loaded text domains.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
@ -1030,7 +1040,8 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
*/
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
/** @var array<string, WP_Translations|NOOP_Translations> $l10n */
global $wp_textdomain_registry, $l10n;
if ( ! is_string( $domain ) ) {
return false;
@ -1040,6 +1051,11 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
$wp_textdomain_registry->set_custom_path( $domain, $path );
// If just-in-time loading was triggered before, reset the entry so it can be tried again.
if ( isset( $l10n[ $domain ] ) && $l10n[ $domain ] instanceof NOOP_Translations ) {
unset( $l10n[ $domain ] );
}
return true;
}
@ -1056,6 +1072,7 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
* @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism.
*
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
* @global array<string, WP_Translations|NOOP_Translations> $l10n An array of all currently loaded text domains.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string|false $path Optional. Path to the directory containing the .mo file.
@ -1064,7 +1081,8 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
*/
function load_theme_textdomain( $domain, $path = false ) {
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
/** @var array<string, WP_Translations|NOOP_Translations> $l10n */
global $wp_textdomain_registry, $l10n;
if ( ! is_string( $domain ) ) {
return false;
@ -1076,6 +1094,11 @@ function load_theme_textdomain( $domain, $path = false ) {
$wp_textdomain_registry->set_custom_path( $domain, $path );
// If just-in-time loading was triggered before, reset the entry so it can be tried again.
if ( isset( $l10n[ $domain ] ) && $l10n[ $domain ] instanceof NOOP_Translations ) {
unset( $l10n[ $domain ] );
}
return true;
}

View File

@ -7,7 +7,11 @@ Version: 1.0.0
Text Domain: custom-internationalized-plugin
*/
load_plugin_textdomain( 'custom-internationalized-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
function custom_i18n_load_textdomain() {
load_plugin_textdomain( 'custom-internationalized-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'custom_i18n_load_textdomain' );
function custom_i18n_plugin_test() {
return __( 'This is a dummy plugin', 'custom-internationalized-plugin' );

View File

@ -342,4 +342,34 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
$this->assertFalse( is_textdomain_loaded( $textdomain ) );
$this->assertSame( 1, $filter->get_call_count() );
}
/**
* @ticket 44937
* @ticket 62337
*
* @covers ::load_plugin_textdomain
* @covers ::is_textdomain_loaded
* @covers WP_Textdomain_Registry::set_custom_path
*/
public function test_plugin_translation_should_be_translated_when_calling_load_plugin_textdomain_too_late() {
require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';
add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
$is_textdomain_loaded_before = is_textdomain_loaded( 'custom-internationalized-plugin' );
$output_before = custom_i18n_plugin_test();
$is_textdomain_loaded_middle = is_textdomain_loaded( 'custom-internationalized-plugin' );
custom_i18n_load_textdomain();
$output_after = custom_i18n_plugin_test();
$is_textdomain_loaded_after = is_textdomain_loaded( 'custom-internationalized-plugin' );
$this->assertFalse( $is_textdomain_loaded_before );
$this->assertFalse( $is_textdomain_loaded_middle );
$this->assertSame( 'This is a dummy plugin', $output_before );
$this->assertSame( 'Das ist ein Dummy Plugin', $output_after );
$this->assertTrue( $is_textdomain_loaded_after );
}
}

View File

@ -493,6 +493,8 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';
custom_i18n_load_textdomain();
$actual = custom_i18n_plugin_test();
switch_to_locale( 'es_ES' );

View File

@ -39,9 +39,10 @@ class Tests_L10n_wpTextdomainRegistry extends WP_UnitTestCase {
$this->instance->has( 'foo' ),
'Incorrect availability status for textdomain with custom path'
);
$this->assertFalse(
$this->assertSame(
WP_LANG_DIR . '/bar/',
$this->instance->get( 'foo', 'en_US' ),
'Should not return custom path for textdomain and en_US locale'
'Should return custom path for textdomain and en_US locale'
);
$this->assertSame(
WP_LANG_DIR . '/bar/',