Make WordPress Core


Ignore:
Timestamp:
08/26/2016 09:37:30 AM (8 years ago)
Author:
wonderboymusic
Message:

L10N: improve accuracy of docs.

Props johnbillion.
Fixes #37585.

File:
1 edited

Legend:

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

    r38284 r38360  
    9292function translate( $text, $domain = 'default' ) {
    9393    $translations = get_translations_for_domain( $domain );
    94     $translations = $translations->translate( $text );
     94    $translation  = $translations->translate( $text );
    9595
    9696    /**
     
    9999     * @since 2.0.11
    100100     *
    101      * @param string $translations Translated text.
     101     * @param string $translation  Translated text.
    102102     * @param string $text         Text to translate.
    103103     * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
    104104     */
    105     return apply_filters( 'gettext', $translations, $text, $domain );
     105    return apply_filters( 'gettext', $translation, $text, $domain );
    106106}
    107107
     
    144144function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    145145    $translations = get_translations_for_domain( $domain );
    146     $translations = $translations->translate( $text, $context );
     146    $translation  = $translations->translate( $text, $context );
    147147    /**
    148148     * Filters text with its translation based on context information.
     
    150150     * @since 2.8.0
    151151     *
    152      * @param string $translations Translated text.
     152     * @param string $translation  Translated text.
    153153     * @param string $text         Text to translate.
    154154     * @param string $context      Context information for the translators.
    155155     * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
    156156     */
    157     return apply_filters( 'gettext_with_context', $translations, $text, $context, $domain );
     157    return apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
    158158}
    159159
     
    319319 * Example:
    320320 *
    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 ) );
    322322 *
    323323 * @since 2.8.0
     
    332332function _n( $single, $plural, $number, $domain = 'default' ) {
    333333    $translations = get_translations_for_domain( $domain );
    334     $translation = $translations->translate_plural( $single, $plural, $number );
     334    $translation  = $translations->translate_plural( $single, $plural, $number );
    335335
    336336    /**
     
    356356 * number is singular or plural.
    357357 *
    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 ) );
    361362 *
    362363 * @since 2.8.0
     
    372373function _nx($single, $plural, $number, $context, $domain = 'default') {
    373374    $translations = get_translations_for_domain( $domain );
    374     $translation = $translations->translate_plural( $single, $plural, $number, $context );
     375    $translation  = $translations->translate_plural( $single, $plural, $number, $context );
    375376
    376377    /**
     
    397398 * Example:
    398399 *
    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' );
    403401 *     ...
    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 ) );
    406403 *
    407404 * @since 2.5.0
     
    432429 * strings and use them later when the number is known.
    433430 *
    434  * Example:
     431 * Example of a generic phrase which is disambiguated via the context parameter:
    435432 *
    436433 *     $messages = array(
    437  *          'post' => _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' ),
    439436 *     );
    440437 *     ...
    441438 *     $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 ) );
    443440 *
    444441 * @since 2.8.0
     
    473470 * Example:
    474471 *
    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' );
    479473 *     ...
    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 ) );
    482475 *
    483476 * @since 3.1.0
Note: See TracChangeset for help on using the changeset viewer.