WordPress.org

Make WordPress Core

Ticket #34213: 34213.2.patch

File 34213.2.patch, 1.8 KB (added by swissspidy, 4 years ago)
  • src/wp-includes/l10n.php

    diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php
    index c017952..8cf0aef 100644
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    681681                $path = WP_PLUGIN_DIR;
    682682        }
    683683
    684         // Load the textdomain according to the plugin first
     684        /*
     685         * Load the plugin textdomain.
     686         *
     687         * Load from the languages directory first,
     688         * otherwise, load the textdomain according to the plugin.
     689         */
    685690        $mofile = $domain . '-' . $locale . '.mo';
    686         if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) )
    687                 return $loaded;
     691        $loaded = load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile );
    688692
    689         // Otherwise, load from the languages directory
    690         $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    691         return load_textdomain( $domain, $mofile );
     693        return ( $loaded ) ? $loaded : load_textdomain( $domain, $path . '/' . $mofile );
    692694}
    693695
    694696/**
    function load_theme_textdomain( $domain, $path = false ) { 
    743745         */
    744746        $locale = apply_filters( 'theme_locale', $locale, $domain );
    745747
    746         if ( ! $path )
     748        if ( ! $path ) {
    747749                $path = get_template_directory();
     750        }
    748751
    749         // Load the textdomain according to the theme
    750         $mofile = untrailingslashit( $path ) . "/{$locale}.mo";
    751         if ( $loaded = load_textdomain( $domain, $mofile ) )
    752                 return $loaded;
     752        /*
     753         * Load the theme textdomain.
     754         *
     755         * Load from the languages directory first,
     756         * otherwise, load the textdomain according to the theme.
     757         */
     758        $mofile = $domain . '-' . $locale . '.mo';
     759        $loaded = load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile );
    753760
    754         // Otherwise, load from the languages directory
    755         $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
    756         return load_textdomain( $domain, $mofile );
     761        return ( $loaded ) ? $loaded : load_textdomain( $domain, $path . '/' . $mofile );
    757762}
    758763
    759764/**