WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/01/2009 08:05:30 PM (12 years ago)
Author:
ryan
Message:

Update load_textdomain() phpdoc. Props nbachiyski. fixes #10286 for 2.8.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.8/wp-includes/l10n.php

    r11641 r11681  
    302302
    303303/**
    304  * Loads MO file into the list of domains.
    305  *
    306  * If the domain already exists, the inclusion will fail. If the MO file is not
    307  * readable, the inclusion will fail.
     304 * Loads a MO file into the domain $domain.
     305 *
     306 * If the domain already exists, the translations will be merged. If both
     307 * sets have the same string, the translation from the original value will be taken.
    308308 *
    309309 * On success, the .mo file will be placed in the $l10n global by $domain
    310  * and will be an gettext_reader object.
     310 * and will be a MO object.
    311311 *
    312312 * @since 1.5.0
    313  * @uses $l10n Gets list of domain translated string (gettext_reader) objects
    314  * @uses CacheFileReader Reads the MO file
    315  * @uses gettext_reader Allows for retrieving translated strings
     313 * @uses $l10n Gets list of domain translated string objects
    316314 *
    317315 * @param string $domain Unique identifier for retrieving translated strings
    318316 * @param string $mofile Path to the .mo file
    319  * @return null On failure returns null and also on success returns nothing.
     317 * @return bool true on success, false on failure
    320318 */
    321319function load_textdomain($domain, $mofile) {
    322320    global $l10n;
    323321
    324     if ( !is_readable($mofile)) return;
     322    if ( !is_readable( $mofile ) ) return false;
    325323
    326324    $mo = new MO();
    327     $mo->import_from_file( $mofile );
    328 
    329     if (isset($l10n[$domain]))
     325    if ( !$mo->import_from_file( $mofile ) ) return false;
     326
     327    if ( isset( $l10n[$domain] ) )
    330328        $mo->merge_with( $l10n[$domain] );
    331329
    332330    $l10n[$domain] = &$mo;
     331    return true;
    333332}
    334333
     
    346345    $mofile = WP_LANG_DIR . "/$locale.mo";
    347346
    348     load_textdomain('default', $mofile);
     347    return load_textdomain('default', $mofile);
    349348}
    350349
     
    373372
    374373    $mofile = $path . '/'. $domain . '-' . $locale . '.mo';
    375     load_textdomain($domain, $mofile);
     374    return load_textdomain($domain, $mofile);
    376375}
    377376
     
    394393
    395394    $mofile = "$path/$locale.mo";
    396     load_textdomain($domain, $mofile);
     395    return load_textdomain($domain, $mofile);
    397396}
    398397
Note: See TracChangeset for help on using the changeset viewer.