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 ) { |
| 630 | 630 | // Unload previously loaded strings so we can switch translations. |
| 631 | 631 | unload_textdomain( 'default' ); |
| 632 | 632 | |
| | 633 | if ( 'en_US' === $locale ) { |
| | 634 | return true; |
| | 635 | } |
| | 636 | |
| 633 | 637 | $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" ); |
| 634 | 638 | |
| 635 | 639 | 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 |
| 674 | 678 | */ |
| 675 | 679 | $locale = apply_filters( 'plugin_locale', $locale, $domain ); |
| 676 | 680 | |
| | 681 | if ( 'en_US' === $locale ) { |
| | 682 | return true; |
| | 683 | } |
| | 684 | |
| 677 | 685 | if ( false !== $plugin_rel_path ) { |
| 678 | 686 | $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' ); |
| 679 | 687 | } elseif ( false !== $deprecated ) { |
| … |
… |
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path |
| 685 | 693 | |
| 686 | 694 | // Load the textdomain according to the plugin first |
| 687 | 695 | $mofile = $domain . '-' . $locale . '.mo'; |
| 688 | | if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) |
| | 696 | if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) { |
| 689 | 697 | return $loaded; |
| | 698 | } |
| 690 | 699 | |
| 691 | 700 | // Otherwise, load from the languages directory |
| 692 | 701 | $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
| … |
… |
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path |
| 706 | 715 | function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { |
| 707 | 716 | /** This filter is documented in wp-includes/l10n.php */ |
| 708 | 717 | $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
| | 718 | |
| | 719 | if ( 'en_US' === $locale ) { |
| | 720 | return true; |
| | 721 | } |
| | 722 | |
| 709 | 723 | $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) ); |
| 710 | 724 | |
| 711 | 725 | // Load the textdomain according to the plugin first |
| 712 | 726 | $mofile = $domain . '-' . $locale . '.mo'; |
| 713 | | if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) |
| | 727 | if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) { |
| 714 | 728 | return $loaded; |
| | 729 | } |
| 715 | 730 | |
| 716 | 731 | // Otherwise, load from the languages directory |
| 717 | 732 | $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
| … |
… |
function load_theme_textdomain( $domain, $path = false ) { |
| 745 | 760 | */ |
| 746 | 761 | $locale = apply_filters( 'theme_locale', $locale, $domain ); |
| 747 | 762 | |
| 748 | | if ( ! $path ) |
| | 763 | if ( 'en_US' === $locale ) { |
| | 764 | return true; |
| | 765 | } |
| | 766 | |
| | 767 | if ( ! $path ) { |
| 749 | 768 | $path = get_template_directory(); |
| | 769 | } |
| 750 | 770 | |
| 751 | 771 | // Load the textdomain according to the theme |
| 752 | 772 | $mofile = untrailingslashit( $path ) . "/{$locale}.mo"; |
| 753 | | if ( $loaded = load_textdomain( $domain, $mofile ) ) |
| | 773 | if ( $loaded = load_textdomain( $domain, $mofile ) ) { |
| 754 | 774 | return $loaded; |
| | 775 | } |
| 755 | 776 | |
| 756 | 777 | // Otherwise, load from the languages directory |
| 757 | 778 | $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo"; |