Ticket #26638: 26638.patch
File 26638.patch, 2.5 KB (added by , 11 years ago) |
---|
-
wp-includes/l10n.php
71 71 * @return string Translated text 72 72 */ 73 73 function translate( $text, $domain = 'default' ) { 74 $translations = get_translations_for_domain( $domain ); 75 $translations = $translations->translate( $text ); 74 if ( is_textdomain_loaded( $domain ) ) { 75 $translations = get_translations_for_domain( $domain ); 76 $translations = $translations->translate( $text ); 77 } else { 78 $translations = $text; 79 } 80 76 81 /** 77 82 * Filter text with its translation. 78 83 * … … 118 123 * @return string Translated text on success, original text on failure. 119 124 */ 120 125 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 121 $translations = get_translations_for_domain( $domain ); 122 $translations = $translations->translate( $text, $context ); 126 if ( is_textdomain_loaded( $domain ) ) { 127 $translations = get_translations_for_domain( $domain ); 128 $translations = $translations->translate( $text, $context ); 129 } else { 130 $translations = $text; 131 } 132 123 133 /** 124 134 * Filter text with its translation based on context information. 125 135 * … … 295 305 * @return string Either $single or $plural translated text. 296 306 */ 297 307 function _n( $single, $plural, $number, $domain = 'default' ) { 298 $translations = get_translations_for_domain( $domain ); 299 $translation = $translations->translate_plural( $single, $plural, $number ); 308 if ( is_textdomain_loaded( $domain ) ) { 309 $translations = get_translations_for_domain( $domain ); 310 $translation = $translations->translate_plural( $single, $plural, $number ); 311 } else { 312 $translation = ( 1 == $number ) ? $single : $plural; 313 } 314 300 315 /** 301 316 * Filter text with its translation when plural option is available. 302 317 * … … 326 341 * @return string Either $single or $plural translated text with context. 327 342 */ 328 343 function _nx($single, $plural, $number, $context, $domain = 'default') { 329 $translations = get_translations_for_domain( $domain ); 330 $translation = $translations->translate_plural( $single, $plural, $number, $context ); 344 if ( is_textdomain_loaded( $domain ) ) { 345 $translations = get_translations_for_domain( $domain ); 346 $translation = $translations->translate_plural( $single, $plural, $number, $context ); 347 } else { 348 $translation = ( 1 == $number ) ? $single : $plural; 349 } 350 331 351 /** 332 352 * Filter text with its translation while plural option and context are available. 333 353 *