Make WordPress Core

Changeset 53543


Ignore:
Timestamp:
06/20/2022 10:55:52 PM (3 years ago)
Author:
johnbillion
Message:

I18N: Correct and improve inline docs and tests for functionality related to nooped plurals.

See #55646, #55652

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r53392 r53543  
    824824 *     @type int|bool $filter                     Whether to enable filtering of the final output
    825825 *                                                via {@see 'wp_generate_tag_cloud'}. Default 1.
    826  *     @type string   $topic_count_text           Nooped plural text from _n_noop() to supply to
     826 *     @type array    $topic_count_text           Nooped plural text from _n_noop() to supply to
    827827 *                                                tag counts. Default null.
    828828 *     @type callable $topic_count_text_callback  Callback used to generate nooped plural text for
  • trunk/src/wp-includes/l10n.php

    r53474 r53543  
    588588 *     Array of translation information for the strings.
    589589 *
    590  *     @type string $0        Singular form to be localized. No longer used.
    591  *     @type string $1        Plural form to be localized. No longer used.
    592  *     @type string $singular Singular form to be localized.
    593  *     @type string $plural   Plural form to be localized.
    594  *     @type null   $context  Context information for the translators.
    595  *     @type string $domain   Text domain.
     590 *     @type string      $0        Singular form to be localized. No longer used.
     591 *     @type string      $1        Plural form to be localized. No longer used.
     592 *     @type string      $singular Singular form to be localized.
     593 *     @type string      $plural   Plural form to be localized.
     594 *     @type null        $context  Context information for the translators.
     595 *     @type string|null $domain   Text domain.
    596596 * }
    597597 */
     
    655655
    656656/**
    657  * Translates and retrieves the singular or plural form of a string that's been registered
     657 * Translates and returns the singular or plural form of a string that's been registered
    658658 * with _n_noop() or _nx_noop().
    659659 *
     
    668668 * @since 3.1.0
    669669 *
    670  * @param array  $nooped_plural Array with singular, plural, and context keys, usually the result of _n_noop() or _nx_noop().
     670 * @param array  $nooped_plural {
     671 *     Array that is usually a return value from _n_noop() or _nx_noop().
     672 *
     673 *     @type string      $singular Singular form to be localized.
     674 *     @type string      $plural   Plural form to be localized.
     675 *     @type string|null $context  Context information for the translators.
     676 *     @type string|null $domain   Text domain.
     677 * }
    671678 * @param int    $count         Number of objects.
    672679 * @param string $domain        Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains
    673680 *                              a text domain passed to _n_noop() or _nx_noop(), it will override this value. Default 'default'.
    674  * @return string Either $single or $plural translated text.
     681 * @return string Either $singular or $plural translated text.
    675682 */
    676683function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
  • trunk/src/wp-includes/post.php

    r53507 r53543  
    12551255 *     @type bool|string $label                     A descriptive name for the post status marked
    12561256 *                                                  for translation. Defaults to value of $post_status.
    1257  *     @type bool|array  $label_count               Descriptive text to use for nooped plurals.
    1258  *                                                  Default array of $label, twice.
     1257 *     @type array|false $label_count               Nooped plural text from _n_noop() to provide the singular
     1258 *                                                  and plural forms of the label for counts. Default false
     1259 *                                                  which means the `$label` argument will be used for both
     1260 *                                                  the singular and plural forms of this label.
    12591261 *     @type bool        $exclude_from_search       Whether to exclude posts with this post status
    12601262 *                                                  from search results. Default is value of $internal.
  • trunk/tests/phpunit/tests/l10n.php

    r52259 r53543  
    2323        $nooped_plural = _n_noop( '%s post', '%s posts', $text_domain );
    2424
    25         $this->assertNotEmpty( $nooped_plural['domain'] );
     25        $this->assertSame( 'text-domain', $nooped_plural['domain'] );
    2626        $this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) );
    2727        $this->assertSame( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) );
     
    3636        $nooped_plural = _nx_noop( '%s post', '%s posts', 'my-context', $text_domain );
    3737
    38         $this->assertNotEmpty( $nooped_plural['domain'] );
    39         $this->assertNotEmpty( $nooped_plural['context'] );
     38        $this->assertSame( 'text-domain', $nooped_plural['domain'] );
     39        $this->assertSame( 'my-context', $nooped_plural['context'] );
    4040        $this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) );
    4141        $this->assertSame( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) );
Note: See TracChangeset for help on using the changeset viewer.