Make WordPress Core

Ticket #25382: 25382.3.diff

File 25382.3.diff, 7.0 KB (added by DrewAPicture, 11 years ago)

Documents two actions that were missed

  • src/wp-includes/l10n.php

     
    2727        global $locale;
    2828
    2929        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                 */
    3037                return apply_filters( 'locale', $locale );
    3138
    3239        // WPLANG is defined in wp-config.
     
    4653        if ( empty( $locale ) )
    4754                $locale = 'en_US';
    4855
     56        // duplicate_hook
    4957        return apply_filters( 'locale', $locale );
    5058}
    5159
     
    6472 */
    6573function translate( $text, $domain = 'default' ) {
    6674        $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       Text domain. Unique identifier for retrieving translated strings.
     83         */
    6784        return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );
    6885}
    6986
     
    101118 */
    102119function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    103120        $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       Text domain. Unique identifier for retrieving translated strings.
     130         */
    104131        return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain );
    105132}
    106133
     
    268295function _n( $single, $plural, $number, $domain = 'default' ) {
    269296        $translations = get_translations_for_domain( $domain );
    270297        $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      Text domain. Unique identifier for retrieving translated strings.
     308         */
    271309        return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
    272310}
    273311
     
    288326function _nx($single, $plural, $number, $context, $domain = 'default') {
    289327        $translations = get_translations_for_domain( $domain );
    290328        $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      Text domain. Unique identifier for retrieving translated strings.
     340         */
    291341        return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
    292342}
    293343
     
    367417function load_textdomain( $domain, $mofile ) {
    368418        global $l10n;
    369419
     420        /**
     421         * Filter text domain and/or MO file path for loading translations.
     422         *
     423         * @since 2.9.0
     424         *
     425         * @param boolean        Whether to override the textomain. Default false.
     426         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     427         * @param string $mofile Path to the MO file.
     428         */
    370429        $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
    371430
    372431        if ( true == $plugin_override ) {
    373432                return true;
    374433        }
    375434
     435        /**
     436         * Fires before the MO translation file is loaded.
     437         *
     438         * @since 2.9.0
     439         *
     440         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     441         * @param string $mofile Path to the .mo file.
     442         */
    376443        do_action( 'load_textdomain', $domain, $mofile );
    377444
     445        /**
     446         * Filter MO file path for loading translations for a specific text domain.
     447         *
     448         * @since 2.9.0
     449         *
     450         * @param string $mofile Path to the MO file.
     451         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     452         */
    378453        $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
    379454
    380455        if ( !is_readable( $mofile ) ) return false;
     
    401476function unload_textdomain( $domain ) {
    402477        global $l10n;
    403478
     479        /**
     480         * Filter text domain for loading translation.
     481         *
     482         * @since 3.0.0
     483         *
     484         * @param boolean        Whether to override unloading the text domain. Default false.
     485         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     486         */
    404487        $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
    405488
    406489        if ( $plugin_override )
    407490                return true;
    408491
     492        /**
     493         * Fires before the text domain is unloaded.
     494         *
     495         * @since 3.0.0
     496         *
     497         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     498         */
    409499        do_action( 'unload_textdomain', $domain );
    410500
    411501        if ( isset( $l10n[$domain] ) ) {
     
    458548 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides.
    459549 */
    460550function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
    461         $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
     551        $locale = get_locale();
     552        /**
     553         * Filter a plugin's locale.
     554         *
     555         * @since 3.0.0
     556         *
     557         * @param string $locale The plugin's current locale.
     558         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     559         */
     560        $locale = apply_filters( 'plugin_locale', $locale, $domain );
    462561
    463562        if ( false !== $plugin_rel_path ) {
    464563                $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
     
    490589 * @return bool True when textdomain is successfully loaded, false otherwise.
    491590 */
    492591function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
     592        // duplicate_hook
    493593        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    494594        $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
    495595
     
    519619 * @return bool True when textdomain is successfully loaded, false otherwise.
    520620 */
    521621function load_theme_textdomain( $domain, $path = false ) {
    522         $locale = apply_filters( 'theme_locale', get_locale(), $domain );
     622        $locale = get_locale();
     623        /**
     624         * Filter a theme's locale.
     625         *
     626         * @since 3.0.0
     627         *
     628         * @param string $locale The theme's current locale.
     629         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     630         */
     631        $locale = apply_filters( 'theme_locale', $locale, $domain );
    523632
    524633        if ( ! $path )
    525634                $path = get_template_directory();