WordPress.org

Make WordPress Core

Ticket #25382: 25382-2.diff

File 25382-2.diff, 12.8 KB (added by Nao, 8 years ago)
  • .php

    old new  
    2727        global $locale;
    2828
    2929        if ( isset( $locale ) )
     30                /**
     31                 * Filter WordPress install's locale ID.
     32                 *
     33                 * @since 1.5.2
     34                 *
     35                 * @param string $locale The locale id.
     36                 */
    3037                return apply_filters( 'locale', $locale );
    3138
    3239        // WPLANG is defined in wp-config.
     
    4653        if ( empty( $locale ) )
    4754                $locale = 'en_US';
    4855
     56        // duplicate_hook
    4957        return apply_filters( 'locale', $locale );
    5058}
    5159
     
    5967 * @since 2.2.0
    6068 *
    6169 * @param string $text   Text to translate.
    62  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     70 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    6371 * @return string Translated text
    6472 */
    6573function translate( $text, $domain = 'default' ) {
    6674        $translations = get_translations_for_domain( $domain );
     75        /**
     76         * Filter text with its translation.
     77         *
     78         * @since 2.0.11
     79         *
     80         * @param string $translations Translated text.
     81         * @param string $text         Text to translate.
     82         * @param string $domain       Optional. Text domain. Unique identifier for retrieving translated strings.
     83         */
    6784        return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );
    6885}
    6986
     
    96113 *
    97114 * @param string $text    Text to translate.
    98115 * @param string $context Context information for the translators.
    99  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     116 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    100117 * @return string Translated text on success, original text on failure.
    101118 */
    102119function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    103120        $translations = get_translations_for_domain( $domain );
     121        /**
     122         * Filter text with its translation based on context information.
     123         *
     124         * @since 2.8.0
     125         *
     126         * @param string $translations Translated text.
     127         * @param string $text         Text to translate.
     128         * @param string $context      Context information for the translators.
     129         * @param string $domain       Optional. Text domain. Unique identifier for retrieving translated strings.
     130         */
    104131        return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain );
    105132}
    106133
     
    111138 * @since 2.1.0
    112139 *
    113140 * @param string $text   Text to translate.
    114  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     141 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    115142 * @return string Translated text.
    116143 */
    117144function __( $text, $domain = 'default' ) {
     
    126153 * @since 2.8.0
    127154 *
    128155 * @param string $text   Text to translate.
    129  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     156 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    130157 * @return string Translated text on success, original text on failure.
    131158 */
    132159function esc_attr__( $text, $domain = 'default' ) {
     
    141168 * @since 2.8.0
    142169 *
    143170 * @param string $text   Text to translate.
    144  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     171 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    145172 * @return string Translated text
    146173 */
    147174function esc_html__( $text, $domain = 'default' ) {
     
    154181 * @since 1.2.0
    155182 *
    156183 * @param string $text   Text to translate.
    157  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     184 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    158185 */
    159186function _e( $text, $domain = 'default' ) {
    160187        echo translate( $text, $domain );
     
    166193 * @since 2.8.0
    167194 *
    168195 * @param string $text   Text to translate.
    169  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     196 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    170197 */
    171198function esc_attr_e( $text, $domain = 'default' ) {
    172199        echo esc_attr( translate( $text, $domain ) );
     
    178205 * @since 2.8.0
    179206 *
    180207 * @param string $text   Text to translate.
    181  * @param string $domain Optional. Unique identifier for retrieving translated strings.
     208 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    182209 */
    183210function esc_html_e( $text, $domain = 'default' ) {
    184211        echo esc_html( translate( $text, $domain ) );
     
    197224 *
    198225 * @param string $text    Text to translate.
    199226 * @param string $context Context information for the translators.
    200  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     227 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    201228 * @return string Translated context string without pipe.
    202229 */
    203230function _x( $text, $context, $domain = 'default' ) {
     
    211238 *
    212239 * @param string $text    Text to translate.
    213240 * @param string $context Context information for the translators.
    214  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     241 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    215242 * @return string Translated context string without pipe.
    216243 */
    217244function _ex( $text, $context, $domain = 'default' ) {
     
    225252 *
    226253 * @param string $text    Text to translate.
    227254 * @param string $context Context information for the translators.
    228  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     255 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    229256 * @return string Translated text
    230257 */
    231258function esc_attr_x( $text, $context, $domain = 'default' ) {
     
    239266 *
    240267 * @param string $text    Text to translate.
    241268 * @param string $context Context information for the translators.
    242  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     269 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    243270 * @return string Translated text.
    244271 */
    245272function esc_html_x( $text, $context, $domain = 'default' ) {
     
    262289 * @param string $single The text that will be used if $number is 1.
    263290 * @param string $plural The text that will be used if $number is not 1.
    264291 * @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.
     292 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
    266293 * @return string Either $single or $plural translated text.
    267294 */
    268295function _n( $single, $plural, $number, $domain = 'default' ) {
    269296        $translations = get_translations_for_domain( $domain );
    270297        $translation = $translations->translate_plural( $single, $plural, $number );
     298        /**
     299         * Filter text with its translation when plural option is available.
     300         *
     301         * @since 2.2.0
     302         *
     303         * @param string $translation Translated text.
     304         * @param string $single      The text that will be used if $number is 1.
     305         * @param string $plural      The text that will be used if $number is not 1.
     306         * @param string $number      The number to compare against to use either $single or $plural.
     307         * @param string $domain      Optional. Text domain. Unique identifier for retrieving translated strings.
     308         */
    271309        return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
    272310}
    273311
     
    282320 * @param string $plural  The text that will be used if $number is not 1.
    283321 * @param int    $number  The number to compare against to use either $single or $plural.
    284322 * @param string $context Context information for the translators.
    285  * @param string $domain  Optional. Unique identifier for retrieving translated strings.
     323 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
    286324 * @return string Either $single or $plural translated text with context.
    287325 */
    288326function _nx($single, $plural, $number, $context, $domain = 'default') {
    289327        $translations = get_translations_for_domain( $domain );
    290328        $translation = $translations->translate_plural( $single, $plural, $number, $context );
     329        /**
     330         * Filter text with its translation while plural option and context are available.
     331         *
     332         * @since 2.8.0
     333         *
     334         * @param string $translation Translated text.
     335         * @param string $single      The text that will be used if $number is 1.
     336         * @param string $plural      The text that will be used if $number is not 1.
     337         * @param string $number      The number to compare against to use either $single or $plural.
     338         * @param string $context     Context information for the translators.
     339         * @param string $domain      Optional. Text domain. Unique identifier for retrieving translated strings.
     340         */
    291341        return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
    292342}
    293343
     
    312362 *
    313363 * @param string $singular Single form to be i18ned.
    314364 * @param string $plural   Plural form to be i18ned.
    315  * @param string $domain   Optional. Unique identifier for retrieving translated strings.
     365 * @param string $domain   Optional. Text domain. Unique identifier for retrieving translated strings.
    316366 * @return array array($singular, $plural)
    317367 */
    318368function _n_noop( $singular, $plural, $domain = null ) {
     
    335385 *
    336386 * @param array  $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop()
    337387 * @param int    $count         Number of objects
    338  * @param string $domain        Optional. Unique identifier for retrieving translated strings. If $nooped_plural contains
     388 * @param string $domain        Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains
    339389 *                              a domain passed to _n_noop() or _nx_noop(), it will override this value.
    340390 * @return string Either $single or $plural translated text.
    341391 */
     
    367417function load_textdomain( $domain, $mofile ) {
    368418        global $l10n;
    369419
     420        /**
     421         * Filter text domain and/or MO file path for loading translations.
     422         *
     423         * @since 2.9.0
     424         *
     425         * @param boolean        False as default.
     426         * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
     427         * @param string $mofile Path to the MO file.
     428         */
    370429        $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
    371430
    372431        if ( true == $plugin_override ) {
     
    375434
    376435        do_action( 'load_textdomain', $domain, $mofile );
    377436
     437        /**
     438         * Filter MO file path for loading translations for a specific text domain.
     439         *
     440         * @since 2.9.0
     441         *
     442         * @param string $mofile Path to the MO file.
     443         * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
     444         */
    378445        $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
    379446
    380447        if ( !is_readable( $mofile ) ) return false;
     
    401468function unload_textdomain( $domain ) {
    402469        global $l10n;
    403470
     471        /**
     472         * Filter text domain for loading translation.
     473         *
     474         * @since 3.0.0
     475         *
     476         * @param boolean        False as default.
     477         * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
     478         */
    404479        $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
    405480
    406481        if ( $plugin_override )
     
    458533 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides.
    459534 */
    460535function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
     536        /**
     537         * Filter plugin's locale.
     538         *
     539         * @since 3.0.0
     540         *
     541         * @param string get_locale() Current locale.
     542         * @param string $domain      Optional. Text domain. Unique identifier for retrieving translated strings.
     543         */
    461544        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    462545
    463546        if ( false !== $plugin_rel_path ) {
     
    490573 * @return bool True when textdomain is successfully loaded, false otherwise.
    491574 */
    492575function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
     576        // duplicate_hook
    493577        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    494578        $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
    495579
     
    519603 * @return bool True when textdomain is successfully loaded, false otherwise.
    520604 */
    521605function load_theme_textdomain( $domain, $path = false ) {
     606        /**
     607         * Filter theme's locale.
     608         *
     609         * @since 3.0.0
     610         *
     611         * @param string get_locale() Current locale.
     612         * @param string $domain      Optional. Text domain. Unique identifier for retrieving translated strings.
     613         */
    522614        $locale = apply_filters( 'theme_locale', get_locale(), $domain );
    523615
    524616        if ( ! $path )