Make WordPress Core

Ticket #10527: 10527.2.patch

File 10527.2.patch, 3.3 KB (added by hakre, 15 years ago)

Updated Patch reflecting defaults and further comment improvements

  • wp-includes/l10n.php

     
    314314 *
    315315 * @param string $domain Unique identifier for retrieving translated strings
    316316 * @param string $mofile Path to the .mo file
     317 * @param bool   $merge  (optional) flag wether or not to merge the .mo file
     318 *                       with an existing textdomain in memory. defaults to
     319 *                       true.
    317320 * @return bool true on success, false on failure
    318321 */
    319 function load_textdomain($domain, $mofile) {
     322function load_textdomain($domain, $mofile, $merge = true) {
    320323        global $l10n;
    321324
    322         if ( !is_readable( $mofile ) ) return false;
     325        if ( isset( $l10n[$domain] ) && false == $merge ) return true;
     326       
     327        if ( !is_readable( $mofile ) ) return false;   
    323328
    324329        $mo = new MO();
    325330        if ( !$mo->import_from_file( $mofile ) ) return false;
    326331
    327         if ( isset( $l10n[$domain] ) )
    328                 $mo->merge_with( $l10n[$domain] );
     332        if ( isset( $l10n[$domain] ) ) $mo->merge_with( $l10n[$domain] );
    329333
    330         $l10n[$domain] = &$mo;
     334        $l10n[$domain] = &$mo; 
    331335        return true;
    332336}
    333337
     
    351355 * Loads the plugin's translated strings.
    352356 *
    353357 * If the path is not given then it will be the root of the plugin directory.
    354  * The .mo file should be named based on the domain with a dash, and then the locale exactly.
     358 * The .mo file should be named based on the domain with a dash, and then the
     359 * locale exactly.
    355360 *
    356361 * @since 1.5.0
    357362 *
    358  * @param string $domain Unique identifier for retrieving translated strings
    359  * @param string $abs_rel_path Optional. Relative path to ABSPATH of a folder,
    360  *      where the .mo file resides. Deprecated, but still functional until 2.7
    361  * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path
     363 * @param string $domain          Name of textdomain
     364 * @param string $abs_rel_path    (optional) Relative path to ABSPATH of a folder,
     365 *                                            where the .mo file resides. Deprecated, but still
     366 *                                functional until 2.7.
     367 * @param string $plugin_rel_path (optional) Relative path to WP_PLUGIN_DIR.
     368 *                                This is the argument to use instead of $abs_rel_path.
     369 * @param bool   $merge           (optional) Flag wether or not to merge the .mo file
     370 *                                with an existing textdomain in memory. default is
     371 *                                false.
     372 * @return bool  true on success, false on failure
    362373 */
    363 function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false) {
     374function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false, $merge = false) {
    364375        $locale = get_locale();
    365376
    366377        if ( false !== $plugin_rel_path )
    367                 $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/');
    368         else if ( false !== $abs_rel_path)
     378                $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
     379        else if ( false !== $abs_rel_path )
    369380                $path = ABSPATH . trim( $abs_rel_path, '/');
    370381        else
    371382                $path = WP_PLUGIN_DIR;
    372383
    373384        $mofile = $path . '/'. $domain . '-' . $locale . '.mo';
    374         return load_textdomain($domain, $mofile);
     385        return load_textdomain( $domain, $mofile, $merge );
    375386}
    376387
    377388/**