Ticket #10971: l10n-translation-noop-performance.patch
File l10n-translation-noop-performance.patch, 2.9 KB (added by , 14 years ago) |
---|
-
wp-includes/l10n.php
55 55 * @return string Translated text 56 56 */ 57 57 function translate( $text, $domain = 'default' ) { 58 $translations = &get_translations_for_domain( $domain ); 59 return apply_filters('gettext', $translations->translate($text), $text, $domain); 58 global $l10n; 59 60 if (isset($l10n[$domain])) 61 return apply_filters('gettext', $l10n[$domain]->translate($text), $text, $domain); 62 else 63 return apply_filters('gettext', $text, $text, $domain); 60 64 } 61 65 62 66 function before_last_bar( $string ) { … … 84 88 } 85 89 86 90 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 87 $translations = &get_translations_for_domain( $domain ); 88 return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain); 91 global $l10n; 92 93 if (isset($l10n[$domain])) 94 return apply_filters('gettext_with_context', $l10n[$domain]->translate($text, $context), $text, $context, $domain); 95 else 96 return apply_filters('gettext_with_context', $text, $text, $context, $domain); 89 97 } 90 98 91 99 /** … … 236 244 * @return string Either $single or $plural translated text 237 245 */ 238 246 function _n($single, $plural, $number, $domain = 'default') { 239 $translations = &get_translations_for_domain( $domain ); 240 $translation = $translations->translate_plural( $single, $plural, $number ); 247 global $l10n; 248 249 if ( isset($l10n[$domain]) ) 250 $translation = $l10n[$domain]->translate_plural( $single, $plural, $number ); 251 else 252 $translation = 1 == $number ? $single : $plural; 253 241 254 return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); 242 255 } 243 256 … … 251 264 } 252 265 253 266 function _nx($single, $plural, $number, $context, $domain = 'default') { 254 $translations = &get_translations_for_domain( $domain ); 255 $translation = $translations->translate_plural( $single, $plural, $number, $context ); 267 global $l10n; 268 269 if ( isset($l10n[$domain]) ) 270 $translation = $l10n[$domain]->translate_plural( $single, $plural, $number, $context ); 271 else 272 $translation = 1 == $number ? $single : $plural; 273 256 274 return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); 257 275 } 258 276 … … 396 414 } 397 415 398 416 /** 399 * Returns the Translations instance for a domain. If there isn't one,400 * returns empty Translations instance.401 *402 * @param string $domain403 * @return object A Translation instance404 */405 function &get_translations_for_domain( $domain ) {406 global $l10n;407 $empty = &new Translations;408 if ( isset($l10n[$domain]) )409 return $l10n[$domain];410 else411 return $empty;412 }413 414 /**415 417 * Translates role name. Since the role names are in the database and 416 418 * not in the source there are dummy gettext calls to get them into the POT 417 419 * file and this function properly translates them back.