WordPress.org

Make WordPress Core

Ticket #21319: 21319.diff

File 21319.diff, 2.2 KB (added by nacin, 3 years ago)
  • wp-includes/l10n.php

     
    6565 * @return string Translated text 
    6666 */ 
    6767function translate( $text, $domain = 'default' ) { 
    68         $translations = &get_translations_for_domain( $domain ); 
     68        $translations = get_translations_for_domain( $domain ); 
    6969        return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain ); 
    7070} 
    7171 
     
    7878} 
    7979 
    8080function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 
    81         $translations = &get_translations_for_domain( $domain ); 
     81        $translations = get_translations_for_domain( $domain ); 
    8282        return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain ); 
    8383} 
    8484 
     
    236236 * @return string Either $single or $plural translated text 
    237237 */ 
    238238function _n( $single, $plural, $number, $domain = 'default' ) { 
    239         $translations = &get_translations_for_domain( $domain ); 
     239        $translations = get_translations_for_domain( $domain ); 
    240240        $translation = $translations->translate_plural( $single, $plural, $number ); 
    241241        return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); 
    242242} 
     
    249249 * 
    250250 */ 
    251251function _nx($single, $plural, $number, $context, $domain = 'default') { 
    252         $translations = &get_translations_for_domain( $domain ); 
     252        $translations = get_translations_for_domain( $domain ); 
    253253        $translation = $translations->translate_plural( $single, $plural, $number, $context ); 
    254254        return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); 
    255255} 
     
    493493 * @param string $domain 
    494494 * @return object A Translation instance 
    495495 */ 
    496 function &get_translations_for_domain( $domain ) { 
     496function get_translations_for_domain( $domain ) { 
    497497        global $l10n; 
    498         if ( !isset( $l10n[$domain] ) ) { 
    499                 $l10n[$domain] = new NOOP_Translations; 
    500         } 
    501         return $l10n[$domain]; 
     498        if ( isset( $l10n[ $domain ] ) ) 
     499                return $l10n[ $domain ]; 
     500 
     501        static $noop_translations; 
     502        if ( ! $noop_translations ) 
     503                $noop_translations = new NOOP_Translations; 
     504        return $noop_translations; 
    502505} 
    503506 
    504507/**