Make WordPress Core

Ticket #36491: 36491-leaner-loading-en_US.patch

File 36491-leaner-loading-en_US.patch, 3.1 KB (added by jrf, 10 years ago)
  • src/wp-includes/l10n.php

    From ce1156cc8a7cf6da7726670458535ca7c8eff954 Mon Sep 17 00:00:00 2001
    Date: Mon, 11 Apr 2016 18:42:18 +0200
    Subject: [PATCH] Don't even attempt to load a translation if the locale is
     `en_US`.
    
    ---
     src/wp-includes/l10n.php | 29 +++++++++++++++++++++++++----
     1 file changed, 25 insertions(+), 4 deletions(-)
    
    diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php
    index bfc6598..d747cc4 100644
    a b function load_default_textdomain( $locale = null ) { 
    630630        // Unload previously loaded strings so we can switch translations.
    631631        unload_textdomain( 'default' );
    632632
     633        if ( 'en_US' === $locale ) {
     634                return true;
     635        }
     636
    633637        $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
    634638
    635639        if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists(  WP_LANG_DIR . "/admin-$locale.mo" ) ) {
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    674678         */
    675679        $locale = apply_filters( 'plugin_locale', $locale, $domain );
    676680
     681        if ( 'en_US' === $locale ) {
     682                return true;
     683        }
     684
    677685        if ( false !== $plugin_rel_path ) {
    678686                $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
    679687        } elseif ( false !== $deprecated ) {
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    685693
    686694        // Load the textdomain according to the plugin first
    687695        $mofile = $domain . '-' . $locale . '.mo';
    688         if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) )
     696        if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) {
    689697                return $loaded;
     698        }
    690699
    691700        // Otherwise, load from the languages directory
    692701        $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    706715function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
    707716        /** This filter is documented in wp-includes/l10n.php */
    708717        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
     718
     719        if ( 'en_US' === $locale ) {
     720                return true;
     721        }
     722
    709723        $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
    710724
    711725        // Load the textdomain according to the plugin first
    712726        $mofile = $domain . '-' . $locale . '.mo';
    713         if ( $loaded = load_textdomain( $domain, $path . $mofile ) )
     727        if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) {
    714728                return $loaded;
     729        }
    715730
    716731        // Otherwise, load from the languages directory
    717732        $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    function load_theme_textdomain( $domain, $path = false ) { 
    745760         */
    746761        $locale = apply_filters( 'theme_locale', $locale, $domain );
    747762
    748         if ( ! $path )
     763        if ( 'en_US' === $locale ) {
     764                return true;
     765        }
     766
     767        if ( ! $path ) {
    749768                $path = get_template_directory();
     769        }
    750770
    751771        // Load the textdomain according to the theme
    752772        $mofile = untrailingslashit( $path ) . "/{$locale}.mo";
    753         if ( $loaded = load_textdomain( $domain, $mofile ) )
     773        if ( $loaded = load_textdomain( $domain, $mofile ) ) {
    754774                return $loaded;
     775        }
    755776
    756777        // Otherwise, load from the languages directory
    757778        $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";