Ticket #10971: l10n-translation-empty-class.patch
File l10n-translation-empty-class.patch, 1.2 KB (added by , 15 years ago) |
---|
-
wp-includes/l10n.php
396 396 } 397 397 398 398 /** 399 * Empty translation class used when no Translation object is available 400 * for domain. 401 * 402 * @package WordPress 403 * @since 2.9.0 404 */ 405 Class Empty_Translation { 406 function translate($text, $context = '') { 407 return $text; 408 } 409 410 function translate_plural($single, $plural, $number) { 411 return $number == 1 ? $single : $plural; 412 } 413 } 414 415 /** 399 416 * Returns the Translations instance for a domain. If there isn't one, 400 * returns empty Translations instance. 417 * returns Empty_Translations instance. That means the only valid methods 418 * are translate() and translate_plural(). 401 419 * 402 420 * @param string $domain 403 * @return object A 421 * @return object An (Empty_)Translation instance 404 422 */ 405 423 function &get_translations_for_domain( $domain ) { 406 424 global $l10n; 407 $empty = &new Translations; 425 static $empty; 426 408 427 if ( isset($l10n[$domain]) ) 409 428 return $l10n[$domain]; 410 else 429 else { 430 if (!isset($empty)) 431 $empty = &new Empty_Translation(); 411 432 return $empty; 433 } 412 434 } 413 435 414 436 /**