Changeset 37414 for trunk/src/wp-includes/l10n.php
- Timestamp:
- 05/10/2016 06:49:21 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/l10n.php
r37342 r37414 656 656 * 657 657 * @since 1.5.0 658 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 658 659 * 659 660 * @param string $domain Unique identifier for retrieving translated strings … … 664 665 */ 665 666 function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { 666 $locale = get_locale();667 667 /** 668 668 * Filter a plugin's locale. … … 673 673 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 674 674 */ 675 $locale = apply_filters( 'plugin_locale', $locale, $domain ); 676 677 if ( false !== $plugin_rel_path ) { 675 $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 676 677 $mofile = $domain . '-' . $locale . '.mo'; 678 679 // Try to load from the languages directory first. 680 if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) { 681 return true; 682 } 683 684 if ( false !== $plugin_rel_path ) { 678 685 $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' ); 679 686 } elseif ( false !== $deprecated ) { … … 684 691 } 685 692 686 // Load the textdomain according to the plugin first 687 $mofile = $domain . '-' . $locale . '.mo'; 688 if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) 689 return $loaded; 690 691 // Otherwise, load from the languages directory 692 $mofile = WP_LANG_DIR . '/plugins/' . $mofile; 693 return load_textdomain( $domain, $mofile ); 693 return load_textdomain( $domain, $path . '/' . $mofile ); 694 694 } 695 695 … … 698 698 * 699 699 * @since 3.0.0 700 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 700 701 * 701 702 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 707 708 /** This filter is documented in wp-includes/l10n.php */ 708 709 $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 710 711 $mofile = $domain . '-' . $locale . '.mo'; 712 713 // Try to load from the languages directory first. 714 if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) { 715 return true; 716 } 717 709 718 $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) ); 710 719 711 // Load the textdomain according to the plugin first 712 $mofile = $domain . '-' . $locale . '.mo'; 713 if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) 714 return $loaded; 715 716 // Otherwise, load from the languages directory 717 $mofile = WP_LANG_DIR . '/plugins/' . $mofile; 718 return load_textdomain( $domain, $mofile ); 720 return load_textdomain( $domain, $path . '/' . $mofile ); 719 721 } 720 722 … … 728 730 * 729 731 * @since 1.5.0 732 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 730 733 * 731 734 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 735 738 */ 736 739 function load_theme_textdomain( $domain, $path = false ) { 737 $locale = get_locale();738 740 /** 739 741 * Filter a theme's locale. … … 744 746 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 745 747 */ 746 $locale = apply_filters( 'theme_locale', $locale, $domain ); 747 748 if ( ! $path ) 748 $locale = apply_filters( 'theme_locale', get_locale(), $domain ); 749 750 $mofile = $domain . '-' . $locale . '.mo'; 751 752 // Try to load from the languages directory first. 753 if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile ) ) { 754 return true; 755 } 756 757 if ( ! $path ) { 749 758 $path = get_template_directory(); 750 751 // Load the textdomain according to the theme 752 $mofile = untrailingslashit( $path ) . "/{$locale}.mo"; 753 if ( $loaded = load_textdomain( $domain, $mofile ) ) 754 return $loaded; 755 756 // Otherwise, load from the languages directory 757 $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo"; 758 return load_textdomain( $domain, $mofile ); 759 } 760 761 return load_textdomain( $domain, $path . '/' . $locale . '.mo' ); 759 762 } 760 763
Note: See TracChangeset
for help on using the changeset viewer.