Make WordPress Core

Changeset 25565


Ignore:
Timestamp:
09/23/2013 12:37:34 AM (11 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/l10n.php.

Props Nao.
Fixes #25382.

File:
1 edited

Legend:

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

    r25536 r25565  
    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
     
    4754        $locale = 'en_US';
    4855
     56    // duplicate_hook
    4957    return apply_filters( 'locale', $locale );
    5058}
     
    6573function translate( $text, $domain = 'default' ) {
    6674    $translations = get_translations_for_domain( $domain );
    67     return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );
     75    $translations = $translations->translate( $text );
     76    /**
     77     * Filter text with its translation.
     78     *
     79     * @since 2.0.11
     80     *
     81     * @param string $translations Translated text.
     82     * @param string $text         Text to translate.
     83     * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
     84     */
     85    return apply_filters( 'gettext', $translations, $text, $domain );
    6886}
    6987
     
    102120function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    103121    $translations = get_translations_for_domain( $domain );
    104     return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain );
     122    $translations = $translations->translate( $text, $context );
     123    /**
     124     * Filter text with its translation based on context information.
     125     *
     126     * @since 2.8.0
     127     *
     128     * @param string $translations Translated text.
     129     * @param string $text         Text to translate.
     130     * @param string $context      Context information for the translators.
     131     * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
     132     */
     133    return apply_filters( 'gettext_with_context', $translations, $text, $context, $domain );
    105134}
    106135
     
    269298    $translations = get_translations_for_domain( $domain );
    270299    $translation = $translations->translate_plural( $single, $plural, $number );
     300    /**
     301     * Filter text with its translation when plural option is available.
     302     *
     303     * @since 2.2.0
     304     *
     305     * @param string $translation Translated text.
     306     * @param string $single      The text that will be used if $number is 1.
     307     * @param string $plural      The text that will be used if $number is not 1.
     308     * @param string $number      The number to compare against to use either $single or $plural.
     309     * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
     310     */
    271311    return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
    272312}
     
    289329    $translations = get_translations_for_domain( $domain );
    290330    $translation = $translations->translate_plural( $single, $plural, $number, $context );
     331    /**
     332     * Filter text with its translation while plural option and context are available.
     333     *
     334     * @since 2.8.0
     335     *
     336     * @param string $translation Translated text.
     337     * @param string $single      The text that will be used if $number is 1.
     338     * @param string $plural      The text that will be used if $number is not 1.
     339     * @param string $number      The number to compare against to use either $single or $plural.
     340     * @param string $context     Context information for the translators.
     341     * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
     342     */
    291343    return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
    292344}
     
    368420    global $l10n;
    369421
     422    /**
     423     * Filter text domain and/or MO file path for loading translations.
     424     *
     425     * @since 2.9.0
     426     *
     427     * @param boolean        Whether to override the text domain. Default false.
     428     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     429     * @param string $mofile Path to the MO file.
     430     */
    370431    $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
    371432
     
    374435    }
    375436
     437    /**
     438     * Fires before the MO translation file is loaded.
     439     *
     440     * @since 2.9.0
     441     *
     442     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     443     * @param string $mofile Path to the .mo file.
     444     */
    376445    do_action( 'load_textdomain', $domain, $mofile );
    377446
     447    /**
     448     * Filter MO file path for loading translations for a specific text domain.
     449     *
     450     * @since 2.9.0
     451     *
     452     * @param string $mofile Path to the MO file.
     453     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     454     */
    378455    $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
    379456
     
    402479    global $l10n;
    403480
     481    /**
     482     * Filter text domain for loading translation.
     483     *
     484     * @since 3.0.0
     485     *
     486     * @param boolean        Whether to override unloading the text domain. Default false.
     487     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     488     */
    404489    $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
    405490
     
    407492        return true;
    408493
     494    /**
     495     * Fires before the text domain is unloaded.
     496     *
     497     * @since 3.0.0
     498     *
     499     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     500     */
    409501    do_action( 'unload_textdomain', $domain );
    410502
     
    459551 */
    460552function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
    461     $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
     553    $locale = get_locale();
     554    /**
     555     * Filter a plugin's locale.
     556     *
     557     * @since 3.0.0
     558     *
     559     * @param string $locale The plugin's current locale.
     560     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     561     */
     562    $locale = apply_filters( 'plugin_locale', $locale, $domain );
    462563
    463564    if ( false !== $plugin_rel_path ) {
     
    491592 */
    492593function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
     594    // duplicate_hook
    493595    $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    494596    $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
     
    520622 */
    521623function load_theme_textdomain( $domain, $path = false ) {
    522     $locale = apply_filters( 'theme_locale', get_locale(), $domain );
     624    $locale = get_locale();
     625    /**
     626     * Filter a theme's locale.
     627     *
     628     * @since 3.0.0
     629     *
     630     * @param string $locale The theme's current locale.
     631     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     632     */
     633    $locale = apply_filters( 'theme_locale', $locale, $domain );
    523634
    524635    if ( ! $path )
Note: See TracChangeset for help on using the changeset viewer.