Skip to content

Commit 14a4682

Browse files
committed
I18N: Correct and improve inline docs and tests for functionality related to nooped plurals.
See #55646, #55652 git-svn-id: https://develop.svn.wordpress.org/trunk@53543 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 268015c commit 14a4682

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

src/wp-includes/category-template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ function default_topic_count_scale( $count ) {
823823
* 'DESC' (descending), or 'RAND' (random). Default 'ASC'.
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
829829
* tag counts based on the count. Default null.

src/wp-includes/l10n.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,12 @@ function _nx( $single, $plural, $number, $context, $domain = 'default' ) {
587587
* @return array {
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
*/
598598
function _n_noop( $singular, $plural, $domain = null ) {
@@ -654,7 +654,7 @@ function _nx_noop( $singular, $plural, $context, $domain = null ) {
654654
}
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
*
660660
* Used when you want to use a translatable plural string once the number is known.
@@ -667,11 +667,18 @@ function _nx_noop( $singular, $plural, $context, $domain = null ) {
667667
*
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
*/
676683
function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
677684
if ( $nooped_plural['domain'] ) {

src/wp-includes/post.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,10 @@ function _wp_privacy_statuses() {
12541254
*
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.
12611263
* @type bool $_builtin Whether the status is built-in. Core-use only.

tests/phpunit/tests/l10n.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function test_n_noop() {
2222
$text_domain = 'text-domain';
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 ) );
2828
$this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) );
@@ -35,8 +35,8 @@ public function test_nx_noop() {
3535
$text_domain = '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 ) );
4242
$this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) );

0 commit comments

Comments
 (0)