@@ -1178,7 +1178,7 @@ public function update( $args, $assoc_args ) {
11781178 wp_version_check ();
11791179
11801180 /**
1181- * @var object{updates: array<object{version: string, locale: string}>} $from_api
1181+ * @var object{updates: array<object{response: string, version: string, locale: string, download: string, packages: object{partial: string|null, new_bundled: string|null, no_content: string|null, full: string} }>} $from_api
11821182 */
11831183 $ from_api = get_site_transient ( 'update_core ' );
11841184
@@ -1198,9 +1198,31 @@ public function update( $args, $assoc_args ) {
11981198 } elseif ( ! empty ( $ from_api ->updates ) ) {
11991199 list ( $ update ) = $ from_api ->updates ;
12001200 }
1201+
1202+ // Override the locale in the transient-based update if --locale is explicitly specified.
1203+ if ( ! empty ( $ update ) ) {
1204+ $ locale_arg = Utils \get_flag_value ( $ assoc_args , 'locale ' );
1205+ if ( $ locale_arg ) {
1206+ $ new_package = $ this ->get_download_url ( $ update ->version , $ locale_arg );
1207+ $ update = (object ) [
1208+ 'response ' => $ update ->response ,
1209+ 'current ' => $ update ->version ,
1210+ 'download ' => $ new_package ,
1211+ 'packages ' => (object ) [
1212+ 'partial ' => null ,
1213+ 'new_bundled ' => $ update ->packages ->new_bundled ,
1214+ 'no_content ' => null ,
1215+ 'full ' => $ new_package ,
1216+ ],
1217+ 'version ' => $ update ->version ,
1218+ 'locale ' => $ locale_arg ,
1219+ ];
1220+ }
1221+ }
12011222 } elseif ( Utils \wp_version_compare ( $ assoc_args ['version ' ], '< ' )
12021223 || 'nightly ' === $ assoc_args ['version ' ]
1203- || Utils \get_flag_value ( $ assoc_args , 'force ' ) ) {
1224+ || Utils \get_flag_value ( $ assoc_args , 'force ' )
1225+ || ! empty ( $ assoc_args ['locale ' ] ) ) {
12041226
12051227 // Specific version is given
12061228 $ version = $ assoc_args ['version ' ];
@@ -1230,7 +1252,8 @@ public function update( $args, $assoc_args ) {
12301252
12311253 if ( ! empty ( $ update )
12321254 && ( $ update ->version !== $ wp_version
1233- || Utils \get_flag_value ( $ assoc_args , 'force ' ) ) ) {
1255+ || Utils \get_flag_value ( $ assoc_args , 'force ' )
1256+ || ( $ update ->locale ?: 'en_US ' ) !== ( self ::get_wp_details ()['wp_local_package ' ] ?: 'en_US ' ) ) ) {
12341257
12351258 require_once ABSPATH . 'wp-admin/includes/upgrade.php ' ;
12361259
0 commit comments