Changeset 38360 for trunk/src/wp-includes/l10n.php
- Timestamp:
- 08/26/2016 09:37:30 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/l10n.php
r38284 r38360 92 92 function translate( $text, $domain = 'default' ) { 93 93 $translations = get_translations_for_domain( $domain ); 94 $translation s= $translations->translate( $text );94 $translation = $translations->translate( $text ); 95 95 96 96 /** … … 99 99 * @since 2.0.11 100 100 * 101 * @param string $translation sTranslated text.101 * @param string $translation Translated text. 102 102 * @param string $text Text to translate. 103 103 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 104 104 */ 105 return apply_filters( 'gettext', $translation s, $text, $domain );105 return apply_filters( 'gettext', $translation, $text, $domain ); 106 106 } 107 107 … … 144 144 function translate_with_gettext_context( $text, $context, $domain = 'default' ) { 145 145 $translations = get_translations_for_domain( $domain ); 146 $translation s= $translations->translate( $text, $context );146 $translation = $translations->translate( $text, $context ); 147 147 /** 148 148 * Filters text with its translation based on context information. … … 150 150 * @since 2.8.0 151 151 * 152 * @param string $translation sTranslated text.152 * @param string $translation Translated text. 153 153 * @param string $text Text to translate. 154 154 * @param string $context Context information for the translators. 155 155 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 156 156 */ 157 return apply_filters( 'gettext_with_context', $translation s, $text, $context, $domain );157 return apply_filters( 'gettext_with_context', $translation, $text, $context, $domain ); 158 158 } 159 159 … … 319 319 * Example: 320 320 * 321 * $people = sprintf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) );321 * printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) ); 322 322 * 323 323 * @since 2.8.0 … … 332 332 function _n( $single, $plural, $number, $domain = 'default' ) { 333 333 $translations = get_translations_for_domain( $domain ); 334 $translation = $translations->translate_plural( $single, $plural, $number );334 $translation = $translations->translate_plural( $single, $plural, $number ); 335 335 336 336 /** … … 356 356 * number is singular or plural. 357 357 * 358 * Example: 359 * 360 * $people = sprintf( _n( '%s person', '%s people', $count, 'context', 'text-domain' ), number_format_i18n( $count ) ); 358 * Example of a generic phrase which is disambiguated via the context parameter: 359 * 360 * printf( _nx( '%s group', '%s groups', $people, 'group of people', 'text-domain' ), number_format_i18n( $people ) ); 361 * printf( _nx( '%s group', '%s groups', $animals, 'group of animals', 'text-domain' ), number_format_i18n( $animals ) ); 361 362 * 362 363 * @since 2.8.0 … … 372 373 function _nx($single, $plural, $number, $context, $domain = 'default') { 373 374 $translations = get_translations_for_domain( $domain ); 374 $translation = $translations->translate_plural( $single, $plural, $number, $context );375 $translation = $translations->translate_plural( $single, $plural, $number, $context ); 375 376 376 377 /** … … 397 398 * Example: 398 399 * 399 * $messages = array( 400 * 'post' => _n_noop( '%s post', '%s posts', 'text-domain' ), 401 * 'page' => _n_noop( '%s pages', '%s pages', 'text-domain' ), 402 * ); 400 * $message = _n_noop( '%s post', '%s posts', 'text-domain' ); 403 401 * ... 404 * $message = $messages[ $type ]; 405 * $usable_text = sprintf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) ); 402 * printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) ); 406 403 * 407 404 * @since 2.5.0 … … 432 429 * strings and use them later when the number is known. 433 430 * 434 * Example :431 * Example of a generic phrase which is disambiguated via the context parameter: 435 432 * 436 433 * $messages = array( 437 * 'p ost' => _n_noop( '%s post', '%s posts', 'context', 'text-domain' ),438 * ' page' => _n_noop( '%s pages', '%s pages', 'context', 'text-domain' ),434 * 'people' => _nx_noop( '%s group', '%s groups', 'people', 'text-domain' ), 435 * 'animals' => _nx_noop( '%s group', '%s groups', 'animals', 'text-domain' ), 439 436 * ); 440 437 * ... 441 438 * $message = $messages[ $type ]; 442 * $usable_text = sprintf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );439 * printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) ); 443 440 * 444 441 * @since 2.8.0 … … 473 470 * Example: 474 471 * 475 * $messages = array( 476 * 'post' => _n_noop( '%s post', '%s posts', 'text-domain' ), 477 * 'page' => _n_noop( '%s pages', '%s pages', 'text-domain' ), 478 * ); 472 * $message = _n_noop( '%s post', '%s posts', 'text-domain' ); 479 473 * ... 480 * $message = $messages[ $type ]; 481 * $usable_text = sprintf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) ); 474 * printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) ); 482 475 * 483 476 * @since 3.1.0
Note: See TracChangeset
for help on using the changeset viewer.