Ticket #9111: deprecate-longer-ngettext-functions.diff
File deprecate-longer-ngettext-functions.diff, 3.2 KB (added by , 16 years ago) |
---|
-
wp-includes/l10n.php
149 149 return translate_with_context($text, $domain); 150 150 } 151 151 152 function __ngettext() { 153 _deprecated_function( __FUNCTION__, '2.8', '_n()' ); 154 $args = func_get_args(); 155 return call_user_func_array('_n', $args); 156 } 157 152 158 /** 153 159 * Retrieve the plural or single form based on the amount. 154 160 * … … 171 177 * @param string $domain Optional. The domain identifier the text should be retrieved in 172 178 * @return string Either $single or $plural translated text 173 179 */ 174 function _ _ngettext($single, $plural, $number, $domain = 'default') {180 function _n($single, $plural, $number, $domain = 'default') { 175 181 global $l10n; 176 182 177 183 if (isset($l10n[$domain])) { … … 185 191 } 186 192 187 193 /** 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 189 196 * 190 197 */ 191 function _n() { 192 $args = func_get_args(); 193 return call_user_func_array('__ngettext', $args); 198 function _nc( $single, $plural, $number, $domain = 'default' ) { 199 return before_last_bar( _n( $single, $plural, $number, $domain ) ); 194 200 } 195 201 196 202 /** 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() 200 204 */ 201 function _nc( $single, $plural, $number, $domain = 'default' ) { 202 return before_last_bar( __ngettext( $single, $plural, $number, $domain ) ); 205 function __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 203 210 } 204 211 205 212 /** … … 210 217 * 211 218 * Example: 212 219 * $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') 215 222 * ); 216 223 * ... 217 224 * $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); 219 226 * 220 227 * @since 2.5 221 228 * @param $single Single form to be i18ned 222 229 * @param $plural Plural form to be i18ned 223 * @param $number Not used, here for compatibility with _ _ngettext, optional224 * @param $domain Not used, here for compatibility with _ _ngettext, optional230 * @param $number Not used, here for compatibility with _n, optional 231 * @param $domain Not used, here for compatibility with _n, optional 225 232 * @return array array($single, $plural) 226 233 */ 227 function _ _ngettext_noop($single, $plural, $number=1, $domain = 'default') {228 return array( $single, $plural);234 function _n_noop( $single, $plural, $number = 1, $domain = 'default' ) { 235 return array( $single, $plural ); 229 236 } 230 237 231 238 /** 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 /**241 239 * Loads MO file into the list of domains. 242 240 * 243 241 * If the domain already exists, the inclusion will fail. If the MO file is not