From 78f74518f15a4dbd764265e0f85032e461de72ab Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Thu, 10 Nov 2022 19:21:12 +0000 Subject: [PATCH] I18N : Always pass `$locale` to `load_textdomain()`. In [53874] the optional `$locale` parameter was added to `load_textdomain()`. While most `load_textdomain()` calls in core were were updated, some were missed. Passing the original locale avoids the need to call `determine_locale()` by `load_textdomain()` which is used as a fallback. Props ocean90, swissspidy, desrosj. Fixes #57060. Built from https://develop.svn.wordpress.org/branches/6.1@54795 git-svn-id: http://core.svn.wordpress.org/branches/6.1@54347 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/admin.php | 4 +++- wp-includes/functions.php | 2 +- wp-includes/load.php | 4 ++-- .../endpoints/class-wp-rest-site-health-controller.php | 2 +- wp-includes/version.php | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php index c2c1890ec8..ce2ec0c68b 100644 --- a/wp-admin/includes/admin.php +++ b/wp-admin/includes/admin.php @@ -13,7 +13,9 @@ if ( ! defined( 'WP_ADMIN' ) ) { * some setup was skipped. Make sure the admin message catalog is loaded since * load_default_textdomain() will not have done so in this context. */ - load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' ); + $admin_locale = get_locale(); + load_textdomain( 'default', WP_LANG_DIR . '/admin-' . $admin_locale . '.mo', $admin_locale ); + unset( $admin_locale ); } /** WordPress Administration Hooks */ diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 563c4d78b8..c14a7c4a7d 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -6347,7 +6347,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) { $locale_loaded = $locale ? $locale : get_locale(); $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; unload_textdomain( 'continents-cities' ); - load_textdomain( 'continents-cities', $mofile ); + load_textdomain( 'continents-cities', $mofile, $locale_loaded ); $mo_loaded = true; } diff --git a/wp-includes/load.php b/wp-includes/load.php index 4986603e9e..bb0db65b94 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -1392,9 +1392,9 @@ function wp_load_translations_early() { foreach ( $locales as $locale ) { foreach ( $locations as $location ) { if ( file_exists( $location . '/' . $locale . '.mo' ) ) { - load_textdomain( 'default', $location . '/' . $locale . '.mo' ); + load_textdomain( 'default', $location . '/' . $locale . '.mo', $locale ); if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { - load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); + load_textdomain( 'default', $location . '/admin-' . $locale . '.mo', $locale ); } break 2; } diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php index 954165b825..43e6676eff 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php @@ -336,7 +336,7 @@ class WP_REST_Site_Health_Controller extends WP_REST_Controller { // Accounts for inner REST API requests in the admin. if ( ! is_admin() ) { $locale = determine_locale(); - load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); + load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo", $locale ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index ac60b66ce0..96f2d565e3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1.1-alpha-54793'; +$wp_version = '6.1.1-alpha-54795'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.