Make WordPress Core

Changeset 54797


Ignore:
Timestamp:
11/10/2022 07:38:20 PM (17 months ago)
Author:
ocean90
Message:

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.
See #57060.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/admin.php

    r47198 r54797  
    1414     * load_default_textdomain() will not have done so in this context.
    1515     */
    16     load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
     16    $admin_locale = get_locale();
     17    load_textdomain( 'default', WP_LANG_DIR . '/admin-' . $admin_locale . '.mo', $admin_locale );
     18    unset( $admin_locale );
    1719}
    1820
  • trunk/src/wp-includes/functions.php

    r54754 r54797  
    63526352        $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
    63536353        unload_textdomain( 'continents-cities' );
    6354         load_textdomain( 'continents-cities', $mofile );
     6354        load_textdomain( 'continents-cities', $mofile, $locale_loaded );
    63556355        $mo_loaded = true;
    63566356    }
  • trunk/src/wp-includes/load.php

    r54637 r54797  
    13931393            foreach ( $locations as $location ) {
    13941394                if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
    1395                     load_textdomain( 'default', $location . '/' . $locale . '.mo' );
     1395                    load_textdomain( 'default', $location . '/' . $locale . '.mo', $locale );
    13961396                    if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) {
    1397                         load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
     1397                        load_textdomain( 'default', $location . '/admin-' . $locale . '.mo', $locale );
    13981398                    }
    13991399                    break 2;
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php

    r54043 r54797  
    337337        if ( ! is_admin() ) {
    338338            $locale = determine_locale();
    339             load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
     339            load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo", $locale );
    340340        }
    341341    }
Note: See TracChangeset for help on using the changeset viewer.