Make WordPress Core

Ticket #9111: deprecate-longer-ngettext-functions.diff

File deprecate-longer-ngettext-functions.diff, 3.2 KB (added by nbachiyski, 16 years ago)
  • wp-includes/l10n.php

     
    149149        return translate_with_context($text, $domain);
    150150}
    151151
     152function __ngettext() {
     153        _deprecated_function( __FUNCTION__, '2.8', '_n()' );
     154        $args = func_get_args();
     155        return call_user_func_array('_n', $args);
     156}
     157
    152158/**
    153159 * Retrieve the plural or single form based on the amount.
    154160 *
     
    171177 * @param string $domain Optional. The domain identifier the text should be retrieved in
    172178 * @return string Either $single or $plural translated text
    173179 */
    174 function __ngettext($single, $plural, $number, $domain = 'default') {
     180function _n($single, $plural, $number, $domain = 'default') {
    175181        global $l10n;
    176182
    177183        if (isset($l10n[$domain])) {
     
    185191}
    186192
    187193/**
    188  * @see __ngettext() An alias of __ngettext
     194 * @see _n() A version of _n(), which supports contexts --
     195 * strips everything from the translation after the last bar
    189196 *
    190197 */
    191 function _n() {
    192         $args = func_get_args();
    193         return call_user_func_array('__ngettext', $args);
     198function _nc( $single, $plural, $number, $domain = 'default' ) {
     199        return before_last_bar( _n( $single, $plural, $number, $domain ) );
    194200}
    195201
    196202/**
    197  * @see _n() A version of _n(), which supports contexts --
    198  * strips everything from the translation after the last bar
    199  *
     203 * @deprecated Use _n_noop()
    200204 */
    201 function _nc( $single, $plural, $number, $domain = 'default' ) {
    202         return before_last_bar( __ngettext( $single, $plural, $number, $domain ) );
     205function __ngettext_noop() {
     206        _deprecated_function( __FUNCTION__, '2.8', '_n_noop()' );
     207        $args = func_get_args();
     208        return call_user_func_array('_n_noop', $args);
     209
    203210}
    204211
    205212/**
     
    210217 *
    211218 * Example:
    212219 *  $messages = array(
    213  *      'post' => ngettext_noop('%s post', '%s posts'),
    214  *      'page' => ngettext_noop('%s pages', '%s pages')
     220 *      'post' => _n_noop('%s post', '%s posts'),
     221 *      'page' => _n_noop('%s pages', '%s pages')
    215222 *  );
    216223 *  ...
    217224 *  $message = $messages[$type];
    218  *  $usable_text = sprintf(__ngettext($message[0], $message[1], $count), $count);
     225 *  $usable_text = sprintf(_n($message[0], $message[1], $count), $count);
    219226 *
    220227 * @since 2.5
    221228 * @param $single Single form to be i18ned
    222229 * @param $plural Plural form to be i18ned
    223  * @param $number Not used, here for compatibility with __ngettext, optional
    224  * @param $domain Not used, here for compatibility with __ngettext, optional
     230 * @param $number Not used, here for compatibility with _n, optional
     231 * @param $domain Not used, here for compatibility with _n, optional
    225232 * @return array array($single, $plural)
    226233 */
    227 function __ngettext_noop($single, $plural, $number=1, $domain = 'default') {
    228         return array($single, $plural);
     234function _n_noop( $single, $plural, $number = 1, $domain = 'default' ) {
     235        return array( $single, $plural );
    229236}
    230237
    231238/**
    232  * @see __ngettext_noop() An alias of __ngettext_noop()
    233  *
    234  */
    235 function _n_noop() {
    236         $args = func_get_args();
    237         return call_user_func_array('__ngettext_noop', $args);
    238 }
    239 
    240 /**
    241239 * Loads MO file into the list of domains.
    242240 *
    243241 * If the domain already exists, the inclusion will fail. If the MO file is not