Make WordPress Core


Ignore:
Timestamp:
01/15/2024 06:55:59 PM (18 months ago)
Author:
swissspidy
Message:

Upgrade/Install: Fix JavaScript localization on install page.

Blocks registration causes scripts to be initialized and localized very early, before the current locale has been properly set on the installation page.

This changes determine_locale() so that the locale chosen during installation is recognized and loaded earlier, ensuring proper script localization.

Props sabernhardt, NekoJonez, jornp, costdev.
Fixes #58696

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/l10n/determineLocale.php

    r56559 r57286  
    2121
    2222    public function tear_down() {
    23         unset( $_SERVER['CONTENT_TYPE'], $_GET['_locale'], $_COOKIE['wp_lang'], $GLOBALS['pagenow'] );
     23        unset(
     24            $_SERVER['CONTENT_TYPE'],
     25            $_GET['_locale'],
     26            $_COOKIE['wp_lang'],
     27            $GLOBALS['pagenow'],
     28            $GLOBALS['wp_local_package'],
     29            $_REQUEST['language']
     30        );
     31        wp_installing( false );
    2432
    2533        parent::tear_down();
     
    274282        $this->assertSame( 'siteLocale', determine_locale() );
    275283    }
     284
     285    public function test_language_param_not_installing() {
     286        $_REQUEST['language'] = 'de_DE';
     287        $this->assertSame( 'en_US', determine_locale() );
     288    }
     289
     290    public function test_language_param_installing() {
     291        $_REQUEST['language'] = 'de_DE';
     292        wp_installing( true );
     293        $this->assertSame( 'de_DE', determine_locale() );
     294    }
     295
     296    public function test_language_param_installing_incorrect_string() {
     297        $_REQUEST['language'] = '####';  // Something sanitize_locale_name() strips away.
     298        wp_installing( true );
     299        $this->assertSame( 'en_US', determine_locale() );
     300    }
     301
     302    public function test_wp_local_package_global_not_installing() {
     303        $_REQUEST['language'] = 'de_DE';
     304        $this->assertSame( 'en_US', determine_locale() );
     305    }
     306    public function test_wp_local_package_global_installing() {
     307        $_REQUEST['language'] = 'de_DE';
     308        wp_installing( true );
     309        $this->assertSame( 'de_DE', determine_locale() );
     310    }
    276311}
Note: See TracChangeset for help on using the changeset viewer.