Make WordPress Core

Ticket #49518: 49518.2.diff

File 49518.2.diff, 5.3 KB (added by garrett-eclipse, 5 years ago)

Updated patch to move domain specific filters after the more general filters

  • src/wp-includes/l10n.php

     
    165165 * *Note:* Don't use translate() directly, use __() or related functions.
    166166 *
    167167 * @since 2.2.0
     168 * @since 5.5.0 Introduced gettext-{$domain} filter.
    168169 *
    169170 * @param string $text   Text to translate.
    170171 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
     
    175176        $translations = get_translations_for_domain( $domain );
    176177        $translation  = $translations->translate( $text );
    177178
     179
    178180        /**
    179181         * Filters text with its translation.
    180182         *
     
    184186         * @param string $text         Text to translate.
    185187         * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
    186188         */
    187         return apply_filters( 'gettext', $translation, $text, $domain );
     189        $translation = apply_filters( 'gettext', $translation, $text, $domain );
     190
     191        /**
     192         * Filters text with its translation for a domain.
     193         *
     194         * @since 5.5.0
     195         *
     196         * @param string $translation  Translated text.
     197         * @param string $text         Text to translate.
     198         */
     199        return apply_filters( 'gettext-' . $domain, $translation, $text );
    188200}
    189201
    190202/**
     
    215227 * *Note:* Don't use translate_with_gettext_context() directly, use _x() or related functions.
    216228 *
    217229 * @since 2.8.0
     230 * @since 5.5.0 Introduced gettext_with_context-{$domain} filter.
    218231 *
    219232 * @param string $text    Text to translate.
    220233 * @param string $context Context information for the translators.
     
    225238function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    226239        $translations = get_translations_for_domain( $domain );
    227240        $translation  = $translations->translate( $text, $context );
     241
    228242        /**
    229243         * Filters text with its translation based on context information.
    230244         *
     
    235249         * @param string $context      Context information for the translators.
    236250         * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
    237251         */
    238         return apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
     252        $translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
     253
     254        /**
     255         * Filters text with its translation based on context information for a domain.
     256         *
     257         * @since 5.5.0
     258         *
     259         * @param string $translation  Translated text.
     260         * @param string $text         Text to translate.
     261         * @param string $context      Context information for the translators.
     262         */
     263        return apply_filters( 'gettext_with_context-' . $domain, $translation, $text, $context );
    239264}
    240265
    241266/**
     
    419444 *     printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) );
    420445 *
    421446 * @since 2.8.0
     447 * @since 5.5.0 Introduced ngettext-{$domain} filter.
    422448 *
    423449 * @param string $single The text to be used if the number is singular.
    424450 * @param string $plural The text to be used if the number is plural.
     
    442468         * @param string $number      The number to compare against to use either the singular or plural form.
    443469         * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
    444470         */
    445         return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
     471        $translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
     472
     473        /**
     474         * Filters the singular or plural form of a string for a domain.
     475         *
     476         * @since 5.5.0
     477         *
     478         * @param string $translation Translated text.
     479         * @param string $single      The text to be used if the number is singular.
     480         * @param string $plural      The text to be used if the number is plural.
     481         * @param string $number      The number to compare against to use either the singular or plural form.
     482         */
     483        return apply_filters( 'ngettext-' . $domain, $translation, $single, $plural, $number );
    446484}
    447485
    448486/**
     
    459497 *     printf( _nx( '%s group', '%s groups', $animals, 'group of animals', 'text-domain' ), number_format_i18n( $animals ) );
    460498 *
    461499 * @since 2.8.0
     500 * @since 5.5.0 Introduced ngettext_with_context-{$domain} filter.
    462501 *
    463502 * @param string $single  The text to be used if the number is singular.
    464503 * @param string $plural  The text to be used if the number is plural.
     
    484523         * @param string $context     Context information for the translators.
    485524         * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
    486525         */
    487         return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
     526        $translation = apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
     527
     528        /**
     529         * Filters the singular or plural form of a string with gettext context for a domain.
     530         *
     531         * @since 5.5.0
     532         *
     533         * @param string $translation Translated text.
     534         * @param string $single      The text to be used if the number is singular.
     535         * @param string $plural      The text to be used if the number is plural.
     536         * @param string $number      The number to compare against to use either the singular or plural form.
     537         * @param string $context     Context information for the translators.
     538         */
     539        return apply_filters( 'ngettext_with_context-' . $domain, $translation, $single, $plural, $number, $context );
    488540}
    489541
    490542/**