WordPress.org

Make WordPress Core

Ticket #35961: 35961.3.patch

File 35961.3.patch, 2.2 KB (added by realloc, 6 years ago)

Interaction with translate_nooped_plural() added

  • src/wp-includes/l10n.php

     
    389389}
    390390
    391391/**
    392  * Registers plural strings in POT file, but don't translate them.
     392 * Registers plural strings in POT file, but does not translate them.
    393393 *
    394394 * Used when you want to keep structures with translatable plural
    395395 * strings and use them later when the number is known.
     
    426426}
    427427
    428428/**
    429  * Register plural strings with gettext context in the POT file, but don't translate them.
     429 * Registers plural strings with gettext context in POT file, but does not translate them.
    430430 *
    431431 * Used when you want to keep structures with translatable plural
    432432 * strings and use them later when the number is known.
  • tests/phpunit/tests/l10n.php

     
    150150                $this->assertNotEmpty( $array['X-Generator'] );
    151151        }
    152152
     153        /**
     154         * @ticket 35961
     155         */
     156        function test_n_noop() {
     157                $text_domain   = 'text-domain';
     158                $nooped_plural = _n_noop( '%s post', '%s posts', $text_domain );
     159
     160                $this->assertNotEmpty( $nooped_plural['domain'] );
     161                $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) );
     162                $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) );
     163                $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) );
     164        }
     165
     166        /**
     167         * @ticket 35961
     168         */
     169        function test_nx_noop() {
     170                $text_domain   = 'text-domain';
     171                $nooped_plural = _nx_noop( '%s post', '%s posts', 'my-context', $text_domain );
     172
     173                $this->assertNotEmpty( $nooped_plural['domain'] );
     174                $this->assertNotEmpty( $nooped_plural['context'] );
     175                $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) );
     176                $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) );
     177                $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) );
     178        }
     179
    153180}