Ticket #10527: 10527.2.patch
File 10527.2.patch, 3.3 KB (added by , 15 years ago) |
---|
-
wp-includes/l10n.php
314 314 * 315 315 * @param string $domain Unique identifier for retrieving translated strings 316 316 * @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. 317 320 * @return bool true on success, false on failure 318 321 */ 319 function load_textdomain($domain, $mofile ) {322 function load_textdomain($domain, $mofile, $merge = true) { 320 323 global $l10n; 321 324 322 if ( !is_readable( $mofile ) ) return false; 325 if ( isset( $l10n[$domain] ) && false == $merge ) return true; 326 327 if ( !is_readable( $mofile ) ) return false; 323 328 324 329 $mo = new MO(); 325 330 if ( !$mo->import_from_file( $mofile ) ) return false; 326 331 327 if ( isset( $l10n[$domain] ) ) 328 $mo->merge_with( $l10n[$domain] ); 332 if ( isset( $l10n[$domain] ) ) $mo->merge_with( $l10n[$domain] ); 329 333 330 $l10n[$domain] = &$mo; 334 $l10n[$domain] = &$mo; 331 335 return true; 332 336 } 333 337 … … 351 355 * Loads the plugin's translated strings. 352 356 * 353 357 * 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. 355 360 * 356 361 * @since 1.5.0 357 362 * 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 362 373 */ 363 function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false ) {374 function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false, $merge = false) { 364 375 $locale = get_locale(); 365 376 366 377 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 ) 369 380 $path = ABSPATH . trim( $abs_rel_path, '/'); 370 381 else 371 382 $path = WP_PLUGIN_DIR; 372 383 373 384 $mofile = $path . '/'. $domain . '-' . $locale . '.mo'; 374 return load_textdomain( $domain, $mofile);385 return load_textdomain( $domain, $mofile, $merge ); 375 386 } 376 387 377 388 /**