Make WordPress Core

Ticket #10286: load_textdomain-docs-and-return-value.diff

File load_textdomain-docs-and-return-value.diff, 2.2 KB (added by nbachiyski, 16 years ago)
  • wp-includes/l10n.php

     
    301301
    302302
    303303/**
    304  * Loads MO file into the list of domains.
     304 * Loads a MO file into the domain $domain.
    305305 *
    306  * If the domain already exists, the inclusion will fail. If the MO file is not
    307  * readable, the inclusion will fail.
     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 );
     325        if ( !$mo->import_from_file( $mofile ) ) return false;
    328326
    329         if (isset($l10n[$domain]))
     327        if ( isset( $l10n[$domain] ) )
    330328                $mo->merge_with( $l10n[$domain] );
    331329
    332330        $l10n[$domain] = &$mo;
     331        return true;
    333332}
    334333
    335334/**
     
    345344
    346345        $mofile = WP_LANG_DIR . "/$locale.mo";
    347346
    348         load_textdomain('default', $mofile);
     347        return load_textdomain('default', $mofile);
    349348}
    350349
    351350/**
     
    372371                $path = WP_PLUGIN_DIR;
    373372
    374373        $mofile = $path . '/'. $domain . '-' . $locale . '.mo';
    375         load_textdomain($domain, $mofile);
     374        return load_textdomain($domain, $mofile);
    376375}
    377376
    378377/**
     
    393392        $path = ( empty( $path ) ) ? get_template_directory() : $path;
    394393
    395394        $mofile = "$path/$locale.mo";
    396         load_textdomain($domain, $mofile);
     395        return load_textdomain($domain, $mofile);
    397396}
    398397
    399398/**