Make WordPress Core

Ticket #24212: 24212.4.diff

File 24212.4.diff, 12.5 KB (added by ericlewis, 12 years ago)
  • wp-includes/l10n.php

     
    5252/**
    5353 * Retrieve the translation of $text.
    5454 *
    55  * If there is no translation, or the domain isn't loaded, the original text is returned.
     55 * If there is no translation, or the text domain isn't loaded, the original text is returned.
    5656 *
    5757 * <strong>Note:</strong> Don't use translate() directly, use __() or related functions.
    5858 *
    5959 * @since 2.2.0
    6060 *
    6161 * @param string $text   Text to translate.
    62  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     62 * @param string $domain Optional. Text domain.
    6363 * @return string Translated text
    6464 */
    6565function translate( $text, $domain = 'default' ) {
     
    8989/**
    9090 * Retrieve the translation of $text in the context defined in $context.
    9191 *
    92  * If there is no translation, or the domain isn't loaded the original
     92 * If there is no translation, or the text domain isn't loaded the original
    9393 * text is returned.
    9494 *
    9595 * @since 2.8.0
    9696 *
    9797 * @param string $text    Text to translate.
    9898 * @param string $context Context information for the translators.
    99  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     99 * @param string $domain  Optional. Text domain.
    100100 * @return string Translated text on success, original text on failure.
    101101 */
    102102function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
     
    106106
    107107/**
    108108 * Retrieve the translation of $text. If there is no translation,
    109  * or the domain isn't loaded, the original text is returned.
     109 * or the text domain isn't loaded, the original text is returned.
    110110 *
    111111 * @since 2.1.0
    112112 *
    113113 * @param string $text   Text to translate.
    114  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     114 * @param string $domain Optional. Text domain.
    115115 * @return string Translated text.
    116116 */
    117117function __( $text, $domain = 'default' ) {
     
    121121/**
    122122 * Retrieve the translation of $text and escapes it for safe use in an attribute.
    123123 *
    124  * If there is no translation, or the domain isn't loaded, the original text is returned.
     124 * If there is no translation, or the text domain isn't loaded, the original text is returned.
    125125 *
    126126 * @since 2.8.0
    127127 *
    128128 * @param string $text   Text to translate.
    129  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     129 * @param string $domain Optional. Text domain.
    130130 * @return string Translated text on success, original text on failure.
    131131 */
    132132function esc_attr__( $text, $domain = 'default' ) {
     
    136136/**
    137137 * Retrieve the translation of $text and escapes it for safe use in HTML output.
    138138 *
    139  * If there is no translation, or the domain isn't loaded, the original text is returned.
     139 * If there is no translation, or the text domain isn't loaded, the original text is returned.
    140140 *
    141141 * @since 2.8.0
    142142 *
    143143 * @param string $text   Text to translate.
    144  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     144 * @param string $domain Optional. Text domain.
    145145 * @return string Translated text
    146146 */
    147147function esc_html__( $text, $domain = 'default' ) {
     
    154154 * @since 1.2.0
    155155 *
    156156 * @param string $text   Text to translate.
    157  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     157 * @param string $domain Optional. Text domain.
    158158 */
    159159function _e( $text, $domain = 'default' ) {
    160160        echo translate( $text, $domain );
     
    166166 * @since 2.8.0
    167167 *
    168168 * @param string $text   Text to translate.
    169  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     169 * @param string $domain Optional. Text domain.
    170170 */
    171171function esc_attr_e( $text, $domain = 'default' ) {
    172172        echo esc_attr( translate( $text, $domain ) );
     
    178178 * @since 2.8.0
    179179 *
    180180 * @param string $text   Text to translate.
    181  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     181 * @param string $domain Optional. Text domain.
    182182 */
    183183function esc_html_e( $text, $domain = 'default' ) {
    184184        echo esc_html( translate( $text, $domain ) );
     
    197197 *
    198198 * @param string $text    Text to translate.
    199199 * @param string $context Context information for the translators.
    200  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     200 * @param string $domain  Optional. Text domain.
    201201 * @return string Translated context string without pipe.
    202202 */
    203203function _x( $text, $context, $domain = 'default' ) {
     
    211211 *
    212212 * @param string $text    Text to translate.
    213213 * @param string $context Context information for the translators.
    214  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     214 * @param string $domain  Optional. Text domain.
    215215 * @return string Translated context string without pipe.
    216216 */
    217217function _ex( $text, $context, $domain = 'default' ) {
     
    219219}
    220220
    221221/**
    222  * Display translated string with gettext context, and escapes it for safe use in an attribute.
     222 * Translate string with gettext context, and escapes it for safe use in an attribute.
    223223 *
    224224 * @since 2.8.0
    225225 *
    226226 * @param string $text    Text to translate.
    227227 * @param string $context Context information for the translators.
    228  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     228 * @param string $domain  Optional. Text domain.
    229229 * @return string Translated text
    230230 */
    231231function esc_attr_x( $text, $context, $domain = 'default' ) {
     
    233233}
    234234
    235235/**
    236  * Display translated string with gettext context, and escapes it for safe use in HTML output.
     236 * Translate string with gettext context, and escapes it for safe use in HTML output.
    237237 *
    238238 * @since 2.9.0
    239239 *
    240240 * @param string $text    Text to translate.
    241241 * @param string $context Context information for the translators.
    242  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     242 * @param string $domain  Optional. Text domain.
    243243 * @return string Translated text.
    244244 */
    245245function esc_html_x( $text, $context, $domain = 'default' ) {
     
    249249/**
    250250 * Retrieve the plural or single form based on the supplied amount.
    251251 *
    252  * If the domain is not set in the $l10n list, then a comparison will be made
     252 * If the text domain is not set in the $l10n list, then a comparison will be made
    253253 * and either $plural or $single parameters returned.
    254254 *
    255  * If the domain does exist, then the parameters $single, $plural, and $number
    256  * will first be passed to the domain's ngettext method. Then it will be passed
     255 * If the text domain does exist, then the parameters $single, $plural, and $number
     256 * will first be passed to the text domain's ngettext method. Then it will be passed
    257257 * to the 'ngettext' filter hook along with the same parameters. The expected
    258258 * type will be a string.
    259259 *
     
    262262 * @param string $single The text that will be used if $number is 1.
    263263 * @param string $plural The text that will be used if $number is not 1.
    264264 * @param int    $number The number to compare against to use either $single or $plural.
    265  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     265 * @param string $domain Optional. Text domain.
    266266 * @return string Either $single or $plural translated text.
    267267 */
    268268function _n( $single, $plural, $number, $domain = 'default' ) {
     
    282282 * @param string $plural  The text that will be used if $number is not 1.
    283283 * @param int    $number  The number to compare against to use either $single or $plural.
    284284 * @param string $context Context information for the translators.
    285  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     285 * @param string $domain  Optional. Text domain.
    286286 * @return string Either $single or $plural translated text with context.
    287287 */
    288288function _nx($single, $plural, $number, $context, $domain = 'default') {
     
    312312 *
    313313 * @param string $singular Single form to be i18ned.
    314314 * @param string $plural   Plural form to be i18ned.
    315  * @param string $domain   Optional. Unique identifier for retrieving translated strings.
     315 * @param string $domain   Optional. Text domain.
    316316 * @return array array($singular, $plural)
    317317 */
    318318function _n_noop( $singular, $plural, $domain = null ) {
     
    335335 *
    336336 * @param array  $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop()
    337337 * @param int    $count         Number of objects
    338  * @param string $domain        Optional. Unique identifier for retrieving translated strings. If $nooped_plural contains
    339  *                              a domain passed to _n_noop() or _nx_noop(), it will override this value.
     338 * @param string $domain        Optional. Text domain. If $nooped_plural contains
     339 *                              a text domain passed to _n_noop() or _nx_noop(), it will override this value.
    340340 * @return string Either $single or $plural translated text.
    341341 */
    342342function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
     
    350350}
    351351
    352352/**
    353  * Load a .mo file into the domain $domain.
     353 * Load a .mo file into the text domain $domain.
    354354 *
    355  * If the domain already exists, the translations will be merged. If both
     355 * If the text domain already exists, the translations will be merged. If both
    356356 * sets have the same string, the translation from the original value will be taken.
    357357 *
    358358 * On success, the .mo file will be placed in the $l10n global by $domain
     
    360360 *
    361361 * @since 1.5.0
    362362 *
    363  * @param string $domain Unique identifier for retrieving translated strings.
     363 * @param string $domain Text domain.
    364364 * @param string $mofile Path to the .mo file.
    365365 * @return bool True on success, false on failure.
    366366 */
     
    391391}
    392392
    393393/**
    394  * Unload translations for a domain.
     394 * Unload translations for a text domain.
    395395 *
    396396 * @since 3.0.0
    397397 *
    398  * @param string $domain Unique identifier for retrieving translated strings.
     398 * @param string $domain Text domain.
    399399 * @return bool Whether textdomain was unloaded.
    400400 */
    401401function unload_textdomain( $domain ) {
     
    449449 *
    450450 * If the path is not given then it will be the root of the plugin directory.
    451451 *
    452  * The .mo file should be named based on the domain with a dash, and then the locale exactly.
     452 * The .mo file should be named based on the text domain with a dash, and then the locale exactly.
    453453 *
    454454 * @since 1.5.0
    455455 *
    456  * @param string $domain          Unique identifier for retrieving translated strings
     456 * @param string $domain          Text domain.
    457457 * @param string $deprecated      Use the $plugin_rel_path parameter instead.
    458458 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides.
    459459 */
     
    484484 *
    485485 * @since 3.0.0
    486486 *
    487  * @param string $domain             Unique identifier for retrieving translated strings.
     487 * @param string $domain             Text domain.
    488488 * @param string $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which the .mo file resides.
    489489 *                                   Default empty string.
    490490 * @return bool True when textdomain is successfully loaded, false otherwise.
     
    513513 *
    514514 * @since 1.5.0
    515515 *
    516  * @param string $domain Unique identifier for retrieving translated strings.
     516 * @param string $domain Text domain.
    517517 * @return bool True when textdomain is successfully loaded, false otherwise.
    518518 */
    519519function load_theme_textdomain( $domain, $path = false ) {
     
    542542 *
    543543 * @since 2.9.0
    544544 *
    545  * @param string $domain Unique identifier for retrieving translated strings.
     545 * @param string $domain Text domain.
    546546 * @return bool True when the theme textdomain is successfully loaded, false otherwise.
    547547 */
    548548function load_child_theme_textdomain( $domain, $path = false ) {
     
    552552}
    553553
    554554/**
    555  * Return the Translations instance for a domain.
     555 * Return the Translations instance for a text domain.
    556556 *
    557557 * If there isn't one, returns empty Translations instance.
    558558 *
    559  * @param string $domain Unique identifier for retrieving translated strings.
     559 * @param string $domain Text domain.
    560560 * @return Translations A Translations instance.
    561561 */
    562562function get_translations_for_domain( $domain ) {
     
    568568}
    569569
    570570/**
    571  * Whether there are translations for the domain
     571 * Whether there are translations for the text domain.
    572572 *
    573573 * @since 3.0.0
    574  * @param string $domain Unique identifier for retrieving translated strings.
     574 * @param string $domain Text domain.
    575575 * @return bool Whether there are translations.
    576576 */
    577577function is_textdomain_loaded( $domain ) {