Ticket #25382: 25382-2.diff
| File 25382-2.diff, 12.8 KB (added by , 12 years ago) |
|---|
-
.php
old new 27 27 global $locale; 28 28 29 29 if ( isset( $locale ) ) 30 /** 31 * Filter WordPress install's locale ID. 32 * 33 * @since 1.5.2 34 * 35 * @param string $locale The locale id. 36 */ 30 37 return apply_filters( 'locale', $locale ); 31 38 32 39 // WPLANG is defined in wp-config. … … 46 53 if ( empty( $locale ) ) 47 54 $locale = 'en_US'; 48 55 56 // duplicate_hook 49 57 return apply_filters( 'locale', $locale ); 50 58 } 51 59 … … 59 67 * @since 2.2.0 60 68 * 61 69 * @param string $text Text to translate. 62 * @param string $domain Optional. Unique identifier for retrieving translated strings.70 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 63 71 * @return string Translated text 64 72 */ 65 73 function translate( $text, $domain = 'default' ) { 66 74 $translations = get_translations_for_domain( $domain ); 75 /** 76 * Filter text with its translation. 77 * 78 * @since 2.0.11 79 * 80 * @param string $translations Translated text. 81 * @param string $text Text to translate. 82 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 83 */ 67 84 return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain ); 68 85 } 69 86 … … 96 113 * 97 114 * @param string $text Text to translate. 98 115 * @param string $context Context information for the translators. 99 * @param string $domain Optional. Unique identifier for retrieving translated strings.116 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 100 117 * @return string Translated text on success, original text on failure. 101 118 */ 102 119 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 103 120 $translations = get_translations_for_domain( $domain ); 121 /** 122 * Filter text with its translation based on context information. 123 * 124 * @since 2.8.0 125 * 126 * @param string $translations Translated text. 127 * @param string $text Text to translate. 128 * @param string $context Context information for the translators. 129 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 130 */ 104 131 return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain ); 105 132 } 106 133 … … 111 138 * @since 2.1.0 112 139 * 113 140 * @param string $text Text to translate. 114 * @param string $domain Optional. Unique identifier for retrieving translated strings.141 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 115 142 * @return string Translated text. 116 143 */ 117 144 function __( $text, $domain = 'default' ) { … … 126 153 * @since 2.8.0 127 154 * 128 155 * @param string $text Text to translate. 129 * @param string $domain Optional. Unique identifier for retrieving translated strings.156 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 130 157 * @return string Translated text on success, original text on failure. 131 158 */ 132 159 function esc_attr__( $text, $domain = 'default' ) { … … 141 168 * @since 2.8.0 142 169 * 143 170 * @param string $text Text to translate. 144 * @param string $domain Optional. Unique identifier for retrieving translated strings.171 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 145 172 * @return string Translated text 146 173 */ 147 174 function esc_html__( $text, $domain = 'default' ) { … … 154 181 * @since 1.2.0 155 182 * 156 183 * @param string $text Text to translate. 157 * @param string $domain Optional. Unique identifier for retrieving translated strings.184 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 158 185 */ 159 186 function _e( $text, $domain = 'default' ) { 160 187 echo translate( $text, $domain ); … … 166 193 * @since 2.8.0 167 194 * 168 195 * @param string $text Text to translate. 169 * @param string $domain Optional. Unique identifier for retrieving translated strings.196 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 170 197 */ 171 198 function esc_attr_e( $text, $domain = 'default' ) { 172 199 echo esc_attr( translate( $text, $domain ) ); … … 178 205 * @since 2.8.0 179 206 * 180 207 * @param string $text Text to translate. 181 * @param string $domain Optional. Unique identifier for retrieving translated strings.208 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 182 209 */ 183 210 function esc_html_e( $text, $domain = 'default' ) { 184 211 echo esc_html( translate( $text, $domain ) ); … … 197 224 * 198 225 * @param string $text Text to translate. 199 226 * @param string $context Context information for the translators. 200 * @param string $domain Optional. Unique identifier for retrieving translated strings.227 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 201 228 * @return string Translated context string without pipe. 202 229 */ 203 230 function _x( $text, $context, $domain = 'default' ) { … … 211 238 * 212 239 * @param string $text Text to translate. 213 240 * @param string $context Context information for the translators. 214 * @param string $domain Optional. Unique identifier for retrieving translated strings.241 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 215 242 * @return string Translated context string without pipe. 216 243 */ 217 244 function _ex( $text, $context, $domain = 'default' ) { … … 225 252 * 226 253 * @param string $text Text to translate. 227 254 * @param string $context Context information for the translators. 228 * @param string $domain Optional. Unique identifier for retrieving translated strings.255 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 229 256 * @return string Translated text 230 257 */ 231 258 function esc_attr_x( $text, $context, $domain = 'default' ) { … … 239 266 * 240 267 * @param string $text Text to translate. 241 268 * @param string $context Context information for the translators. 242 * @param string $domain Optional. Unique identifier for retrieving translated strings.269 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 243 270 * @return string Translated text. 244 271 */ 245 272 function esc_html_x( $text, $context, $domain = 'default' ) { … … 262 289 * @param string $single The text that will be used if $number is 1. 263 290 * @param string $plural The text that will be used if $number is not 1. 264 291 * @param int $number The number to compare against to use either $single or $plural. 265 * @param string $domain Optional. Unique identifier for retrieving translated strings.292 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 266 293 * @return string Either $single or $plural translated text. 267 294 */ 268 295 function _n( $single, $plural, $number, $domain = 'default' ) { 269 296 $translations = get_translations_for_domain( $domain ); 270 297 $translation = $translations->translate_plural( $single, $plural, $number ); 298 /** 299 * Filter text with its translation when plural option is available. 300 * 301 * @since 2.2.0 302 * 303 * @param string $translation Translated text. 304 * @param string $single The text that will be used if $number is 1. 305 * @param string $plural The text that will be used if $number is not 1. 306 * @param string $number The number to compare against to use either $single or $plural. 307 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 308 */ 271 309 return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); 272 310 } 273 311 … … 282 320 * @param string $plural The text that will be used if $number is not 1. 283 321 * @param int $number The number to compare against to use either $single or $plural. 284 322 * @param string $context Context information for the translators. 285 * @param string $domain Optional. Unique identifier for retrieving translated strings.323 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 286 324 * @return string Either $single or $plural translated text with context. 287 325 */ 288 326 function _nx($single, $plural, $number, $context, $domain = 'default') { 289 327 $translations = get_translations_for_domain( $domain ); 290 328 $translation = $translations->translate_plural( $single, $plural, $number, $context ); 329 /** 330 * Filter text with its translation while plural option and context are available. 331 * 332 * @since 2.8.0 333 * 334 * @param string $translation Translated text. 335 * @param string $single The text that will be used if $number is 1. 336 * @param string $plural The text that will be used if $number is not 1. 337 * @param string $number The number to compare against to use either $single or $plural. 338 * @param string $context Context information for the translators. 339 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 340 */ 291 341 return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); 292 342 } 293 343 … … 312 362 * 313 363 * @param string $singular Single form to be i18ned. 314 364 * @param string $plural Plural form to be i18ned. 315 * @param string $domain Optional. Unique identifier for retrieving translated strings.365 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 316 366 * @return array array($singular, $plural) 317 367 */ 318 368 function _n_noop( $singular, $plural, $domain = null ) { … … 335 385 * 336 386 * @param array $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop() 337 387 * @param int $count Number of objects 338 * @param string $domain Optional. Unique identifier for retrieving translated strings. If $nooped_plural contains388 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains 339 389 * a domain passed to _n_noop() or _nx_noop(), it will override this value. 340 390 * @return string Either $single or $plural translated text. 341 391 */ … … 367 417 function load_textdomain( $domain, $mofile ) { 368 418 global $l10n; 369 419 420 /** 421 * Filter text domain and/or MO file path for loading translations. 422 * 423 * @since 2.9.0 424 * 425 * @param boolean False as default. 426 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 427 * @param string $mofile Path to the MO file. 428 */ 370 429 $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile ); 371 430 372 431 if ( true == $plugin_override ) { … … 375 434 376 435 do_action( 'load_textdomain', $domain, $mofile ); 377 436 437 /** 438 * Filter MO file path for loading translations for a specific text domain. 439 * 440 * @since 2.9.0 441 * 442 * @param string $mofile Path to the MO file. 443 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 444 */ 378 445 $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain ); 379 446 380 447 if ( !is_readable( $mofile ) ) return false; … … 401 468 function unload_textdomain( $domain ) { 402 469 global $l10n; 403 470 471 /** 472 * Filter text domain for loading translation. 473 * 474 * @since 3.0.0 475 * 476 * @param boolean False as default. 477 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 478 */ 404 479 $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain ); 405 480 406 481 if ( $plugin_override ) … … 458 533 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides. 459 534 */ 460 535 function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { 536 /** 537 * Filter plugin's locale. 538 * 539 * @since 3.0.0 540 * 541 * @param string get_locale() Current locale. 542 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 543 */ 461 544 $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 462 545 463 546 if ( false !== $plugin_rel_path ) { … … 490 573 * @return bool True when textdomain is successfully loaded, false otherwise. 491 574 */ 492 575 function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { 576 // duplicate_hook 493 577 $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 494 578 $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) ); 495 579 … … 519 603 * @return bool True when textdomain is successfully loaded, false otherwise. 520 604 */ 521 605 function load_theme_textdomain( $domain, $path = false ) { 606 /** 607 * Filter theme's locale. 608 * 609 * @since 3.0.0 610 * 611 * @param string get_locale() Current locale. 612 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 613 */ 522 614 $locale = apply_filters( 'theme_locale', get_locale(), $domain ); 523 615 524 616 if ( ! $path )