Make WordPress Core

Ticket #16750: 16750.4.diff

File 16750.4.diff, 13.2 KB (added by DrewAPicture, 12 years ago)
  • src/wp-includes/l10n.php

     
    6060/**
    6161 * Retrieve the translation of $text.
    6262 *
    63  * If there is no translation, or the domain isn't loaded, the original text is returned.
     63 * If there is no translation, or the text domain isn't loaded, the original text is returned.
    6464 *
    6565 * <strong>Note:</strong> Don't use translate() directly, use __() or related functions.
    6666 *
    6767 * @since 2.2.0
    6868 *
    6969 * @param string $text   Text to translate.
    70  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     70 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    7171 * @return string Translated text
    7272 */
    7373function translate( $text, $domain = 'default' ) {
     
    107107/**
    108108 * Retrieve the translation of $text in the context defined in $context.
    109109 *
    110  * If there is no translation, or the domain isn't loaded the original
     110 * If there is no translation, or the text domain isn't loaded the original
    111111 * text is returned.
    112112 *
    113113 * @since 2.8.0
    114114 *
    115115 * @param string $text    Text to translate.
    116116 * @param string $context Context information for the translators.
    117  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     117 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    118118 * @return string Translated text on success, original text on failure.
    119119 */
    120120function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
     
    135135
    136136/**
    137137 * Retrieve the translation of $text. If there is no translation,
    138  * or the domain isn't loaded, the original text is returned.
     138 * or the text domain isn't loaded, the original text is returned.
    139139 *
    140140 * @since 2.1.0
    141141 *
    142142 * @param string $text   Text to translate.
    143  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     143 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    144144 * @return string Translated text.
    145145 */
    146146function __( $text, $domain = 'default' ) {
     
    150150/**
    151151 * Retrieve the translation of $text and escapes it for safe use in an attribute.
    152152 *
    153  * If there is no translation, or the domain isn't loaded, the original text is returned.
     153 * If there is no translation, or the text domain isn't loaded, the original text is returned.
    154154 *
    155155 * @since 2.8.0
    156156 *
    157157 * @param string $text   Text to translate.
    158  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     158 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    159159 * @return string Translated text on success, original text on failure.
    160160 */
    161161function esc_attr__( $text, $domain = 'default' ) {
     
    165165/**
    166166 * Retrieve the translation of $text and escapes it for safe use in HTML output.
    167167 *
    168  * If there is no translation, or the domain isn't loaded, the original text is returned.
     168 * If there is no translation, or the text domain isn't loaded, the original text is returned.
    169169 *
    170170 * @since 2.8.0
    171171 *
    172172 * @param string $text   Text to translate.
    173  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     173 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    174174 * @return string Translated text
    175175 */
    176176function esc_html__( $text, $domain = 'default' ) {
     
    183183 * @since 1.2.0
    184184 *
    185185 * @param string $text   Text to translate.
    186  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     186 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    187187 */
    188188function _e( $text, $domain = 'default' ) {
    189189        echo translate( $text, $domain );
     
    195195 * @since 2.8.0
    196196 *
    197197 * @param string $text   Text to translate.
    198  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     198 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    199199 */
    200200function esc_attr_e( $text, $domain = 'default' ) {
    201201        echo esc_attr( translate( $text, $domain ) );
     
    207207 * @since 2.8.0
    208208 *
    209209 * @param string $text   Text to translate.
    210  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     210 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    211211 */
    212212function esc_html_e( $text, $domain = 'default' ) {
    213213        echo esc_html( translate( $text, $domain ) );
     
    226226 *
    227227 * @param string $text    Text to translate.
    228228 * @param string $context Context information for the translators.
    229  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     229 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    230230 * @return string Translated context string without pipe.
    231231 */
    232232function _x( $text, $context, $domain = 'default' ) {
     
    240240 *
    241241 * @param string $text    Text to translate.
    242242 * @param string $context Context information for the translators.
    243  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     243 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    244244 * @return string Translated context string without pipe.
    245245 */
    246246function _ex( $text, $context, $domain = 'default' ) {
     
    254254 *
    255255 * @param string $text    Text to translate.
    256256 * @param string $context Context information for the translators.
    257  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     257 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    258258 * @return string Translated text
    259259 */
    260260function esc_attr_x( $text, $context, $domain = 'default' ) {
     
    268268 *
    269269 * @param string $text    Text to translate.
    270270 * @param string $context Context information for the translators.
    271  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     271 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    272272 * @return string Translated text.
    273273 */
    274274function esc_html_x( $text, $context, $domain = 'default' ) {
     
    278278/**
    279279 * Retrieve the plural or single form based on the supplied amount.
    280280 *
    281  * If the domain is not set in the $l10n list, then a comparison will be made
     281 * If the text domain is not set in the $l10n list, then a comparison will be made
    282282 * and either $plural or $single parameters returned.
    283283 *
    284  * If the domain does exist, then the parameters $single, $plural, and $number
    285  * will first be passed to the domain's ngettext method. Then it will be passed
     284 * If the text domain does exist, then the parameters $single, $plural, and $number
     285 * will first be passed to the text domain's ngettext method. Then it will be passed
    286286 * to the 'ngettext' filter hook along with the same parameters. The expected
    287287 * type will be a string.
    288288 *
     
    291291 * @param string $single The text that will be used if $number is 1.
    292292 * @param string $plural The text that will be used if $number is not 1.
    293293 * @param int    $number The number to compare against to use either $single or $plural.
    294  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     294 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    295295 * @return string Either $single or $plural translated text.
    296296 */
    297297function _n( $single, $plural, $number, $domain = 'default' ) {
     
    322322 * @param string $plural  The text that will be used if $number is not 1.
    323323 * @param int    $number  The number to compare against to use either $single or $plural.
    324324 * @param string $context Context information for the translators.
    325  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     325 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    326326 * @return string Either $single or $plural translated text with context.
    327327 */
    328328function _nx($single, $plural, $number, $context, $domain = 'default') {
     
    364364 *
    365365 * @param string $singular Single form to be i18ned.
    366366 * @param string $plural   Plural form to be i18ned.
    367  * @param string $domain   Optional. Unique identifier for retrieving translated strings.
     367 * @param string $domain   Optional. Text domain. Unique identifier for retrieving translated strings.
    368368 * @return array array($singular, $plural)
    369369 */
    370370function _n_noop( $singular, $plural, $domain = null ) {
     
    387387 *
    388388 * @param array  $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop()
    389389 * @param int    $count         Number of objects
    390  * @param string $domain        Optional. Unique identifier for retrieving translated strings. If $nooped_plural contains
    391  *                              a domain passed to _n_noop() or _nx_noop(), it will override this value.
     390 * @param string $domain        Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains
     391 *                              a text domain passed to _n_noop() or _nx_noop(), it will override this value.
    392392 * @return string Either $single or $plural translated text.
    393393 */
    394394function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
     
    402402}
    403403
    404404/**
    405  * Load a .mo file into the domain $domain.
     405 * Load a .mo file into the text domain $domain.
    406406 *
    407  * If the domain already exists, the translations will be merged. If both
     407 * If the text domain already exists, the translations will be merged. If both
    408408 * sets have the same string, the translation from the original value will be taken.
    409409 *
    410410 * On success, the .mo file will be placed in the $l10n global by $domain
     
    412412 *
    413413 * @since 1.5.0
    414414 *
    415  * @param string $domain Unique identifier for retrieving translated strings.
     415 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    416416 * @param string $mofile Path to the .mo file.
    417417 * @return bool True on success, false on failure.
    418418 */
     
    468468}
    469469
    470470/**
    471  * Unload translations for a domain.
     471 * Unload translations for a text domain.
    472472 *
    473473 * @since 3.0.0
    474474 *
    475  * @param string $domain Unique identifier for retrieving translated strings.
     475 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    476476 * @return bool Whether textdomain was unloaded.
    477477 */
    478478function unload_textdomain( $domain ) {
    479479        global $l10n;
    480480
    481481        /**
    482          * Filter text domain for loading translation.
     482         * Filter text text domain for loading translation.
    483483         *
    484484         * @since 3.0.0
    485485         *
     
    541541 *
    542542 * If the path is not given then it will be the root of the plugin directory.
    543543 *
    544  * The .mo file should be named based on the domain with a dash, and then the locale exactly.
     544 * The .mo file should be named based on the text domain with a dash, and then the locale exactly.
    545545 *
    546546 * @since 1.5.0
    547547 *
     
    585585 *
    586586 * @since 3.0.0
    587587 *
    588  * @param string $domain             Unique identifier for retrieving translated strings.
     588 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
    589589 * @param string $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which the .mo file resides.
    590590 *                                   Default empty string.
    591591 * @return bool True when textdomain is successfully loaded, false otherwise.
     
    615615 *
    616616 * @since 1.5.0
    617617 *
    618  * @param string $domain Unique identifier for retrieving translated strings.
     618 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    619619 * @param string $path   Optional. Path to the directory containing the .mo file.
    620620 *                       Default false.
    621621 * @return bool True when textdomain is successfully loaded, false otherwise.
     
    655655 *
    656656 * @since 2.9.0
    657657 *
    658  * @param string $domain Unique identifier for retrieving translated strings.
     658 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    659659 * @return bool True when the theme textdomain is successfully loaded, false otherwise.
    660660 */
    661661function load_child_theme_textdomain( $domain, $path = false ) {
     
    665665}
    666666
    667667/**
    668  * Return the Translations instance for a domain.
     668 * Return the Translations instance for a text domain.
    669669 *
    670670 * If there isn't one, returns empty Translations instance.
    671671 *
    672  * @param string $domain Unique identifier for retrieving translated strings.
     672 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    673673 * @return Translations A Translations instance.
    674674 */
    675675function get_translations_for_domain( $domain ) {
     
    681681}
    682682
    683683/**
    684  * Whether there are translations for the domain
     684 * Whether there are translations for the text domain.
    685685 *
    686686 * @since 3.0.0
    687  * @param string $domain Unique identifier for retrieving translated strings.
     687 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    688688 * @return bool Whether there are translations.
    689689 */
    690690function is_textdomain_loaded( $domain ) {