WordPress.org

Make WordPress Core

Changeset 20648


Ignore:
Timestamp:
04/30/12 16:18:35 (3 years ago)
Author:
nacin
Message:

Allow nooped plurals to receive a textdomain on registration to then be used on translation.

This is good for when the code registering the plural is not also translating it. This occurs
in core with register_post_status(), which accepts a nooped plural as an argument, and then
calls translate_nooped_plural() without a domain.

translate_nooped_plural() can still be called with a domain. The argument will just be overridden
if the nooped plural contains a domain key.

fixes #20188.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/l10n.php

    r19772 r20648  
    273273 * @param string $singular Single form to be i18ned 
    274274 * @param string $plural Plural form to be i18ned 
     275 * @param string $domain Optional. The domain identifier the text will be retrieved in 
    275276 * @return array array($singular, $plural) 
    276277 */ 
    277 function _n_noop( $singular, $plural ) { 
    278     return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null ); 
     278function _n_noop( $singular, $plural, $domain = null ) { 
     279    return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain ); 
    279280} 
    280281 
     
    284285 * @see _n_noop() 
    285286 */ 
    286 function _nx_noop( $singular, $plural, $context ) { 
    287     return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context ); 
     287function _nx_noop( $singular, $plural, $context, $domain = null ) { 
     288    return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain ); 
    288289} 
    289290 
     
    294295 * @param array $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop() 
    295296 * @param int $count Number of objects 
    296  * @param string $domain Optional. The domain identifier the text should be retrieved in 
     297 * @param string $domain Optional. The domain identifier the text should be retrieved in. If $nooped_plural contains 
     298 *  a domain passed to _n_noop() or _nx_noop(), it will override this value. 
    297299 */ 
    298300function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) { 
     301    if ( $nooped_plural['domain'] ) 
     302        $domain = $nooped_plural['domain']; 
     303 
    299304    if ( $nooped_plural['context'] ) 
    300305        return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); 
Note: See TracChangeset for help on using the changeset viewer.