Changeset 25565
- Timestamp:
- 09/23/2013 12:37:34 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/l10n.php
r25536 r25565 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 … … 47 54 $locale = 'en_US'; 48 55 56 // duplicate_hook 49 57 return apply_filters( 'locale', $locale ); 50 58 } … … 65 73 function translate( $text, $domain = 'default' ) { 66 74 $translations = get_translations_for_domain( $domain ); 67 return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain ); 75 $translations = $translations->translate( $text ); 76 /** 77 * Filter text with its translation. 78 * 79 * @since 2.0.11 80 * 81 * @param string $translations Translated text. 82 * @param string $text Text to translate. 83 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 84 */ 85 return apply_filters( 'gettext', $translations, $text, $domain ); 68 86 } 69 87 … … 102 120 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 103 121 $translations = get_translations_for_domain( $domain ); 104 return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain ); 122 $translations = $translations->translate( $text, $context ); 123 /** 124 * Filter text with its translation based on context information. 125 * 126 * @since 2.8.0 127 * 128 * @param string $translations Translated text. 129 * @param string $text Text to translate. 130 * @param string $context Context information for the translators. 131 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 132 */ 133 return apply_filters( 'gettext_with_context', $translations, $text, $context, $domain ); 105 134 } 106 135 … … 269 298 $translations = get_translations_for_domain( $domain ); 270 299 $translation = $translations->translate_plural( $single, $plural, $number ); 300 /** 301 * Filter text with its translation when plural option is available. 302 * 303 * @since 2.2.0 304 * 305 * @param string $translation Translated text. 306 * @param string $single The text that will be used if $number is 1. 307 * @param string $plural The text that will be used if $number is not 1. 308 * @param string $number The number to compare against to use either $single or $plural. 309 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 310 */ 271 311 return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); 272 312 } … … 289 329 $translations = get_translations_for_domain( $domain ); 290 330 $translation = $translations->translate_plural( $single, $plural, $number, $context ); 331 /** 332 * Filter text with its translation while plural option and context are available. 333 * 334 * @since 2.8.0 335 * 336 * @param string $translation Translated text. 337 * @param string $single The text that will be used if $number is 1. 338 * @param string $plural The text that will be used if $number is not 1. 339 * @param string $number The number to compare against to use either $single or $plural. 340 * @param string $context Context information for the translators. 341 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 342 */ 291 343 return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); 292 344 } … … 368 420 global $l10n; 369 421 422 /** 423 * Filter text domain and/or MO file path for loading translations. 424 * 425 * @since 2.9.0 426 * 427 * @param boolean Whether to override the text domain. Default false. 428 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 429 * @param string $mofile Path to the MO file. 430 */ 370 431 $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile ); 371 432 … … 374 435 } 375 436 437 /** 438 * Fires before the MO translation file is loaded. 439 * 440 * @since 2.9.0 441 * 442 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 443 * @param string $mofile Path to the .mo file. 444 */ 376 445 do_action( 'load_textdomain', $domain, $mofile ); 377 446 447 /** 448 * Filter MO file path for loading translations for a specific text domain. 449 * 450 * @since 2.9.0 451 * 452 * @param string $mofile Path to the MO file. 453 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 454 */ 378 455 $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain ); 379 456 … … 402 479 global $l10n; 403 480 481 /** 482 * Filter text domain for loading translation. 483 * 484 * @since 3.0.0 485 * 486 * @param boolean Whether to override unloading the text domain. Default false. 487 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 488 */ 404 489 $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain ); 405 490 … … 407 492 return true; 408 493 494 /** 495 * Fires before the text domain is unloaded. 496 * 497 * @since 3.0.0 498 * 499 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 500 */ 409 501 do_action( 'unload_textdomain', $domain ); 410 502 … … 459 551 */ 460 552 function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { 461 $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 553 $locale = get_locale(); 554 /** 555 * Filter a plugin's locale. 556 * 557 * @since 3.0.0 558 * 559 * @param string $locale The plugin's current locale. 560 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 561 */ 562 $locale = apply_filters( 'plugin_locale', $locale, $domain ); 462 563 463 564 if ( false !== $plugin_rel_path ) { … … 491 592 */ 492 593 function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { 594 // duplicate_hook 493 595 $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 494 596 $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) ); … … 520 622 */ 521 623 function load_theme_textdomain( $domain, $path = false ) { 522 $locale = apply_filters( 'theme_locale', get_locale(), $domain ); 624 $locale = get_locale(); 625 /** 626 * Filter a theme's locale. 627 * 628 * @since 3.0.0 629 * 630 * @param string $locale The theme's current locale. 631 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 632 */ 633 $locale = apply_filters( 'theme_locale', $locale, $domain ); 523 634 524 635 if ( ! $path )
Note: See TracChangeset
for help on using the changeset viewer.