Ticket #9686: hooks-and-unload_textdomain.2.diff
File hooks-and-unload_textdomain.2.diff, 3.0 KB (added by , 15 years ago) |
---|
-
wp-includes/l10n.php
69 69 return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain ); 70 70 } 71 71 72 function before_last_bar( $string ) { 72 function before_last_bar( $string ) { 73 73 $last_bar = strrpos( $string, '|' ); 74 74 if ( false == $last_bar ) 75 75 return $string; … … 310 310 $mo->merge_with( $l10n[$domain] ); 311 311 312 312 $l10n[$domain] = &$mo; 313 313 314 314 return true; 315 315 } 316 316 317 317 /** 318 * Unloads translations for a domain 319 * 320 * @since 3.0 321 * @param string $domain Textdomain to be unloaded 322 */ 323 function unload_textdomain( $domain ) { 324 global $l10n; 325 326 $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain ); 327 328 if ( true == $plugin_override ) { 329 return true; 330 } 331 332 do_action( 'unload_textdomain', $domain ); 333 334 if ( isset( $l10n[$domain] ) ) { 335 unset( $l10n[$domain] ); 336 return true; 337 } 338 339 return false; 340 } 341 342 /** 318 343 * Loads default translated strings based on locale. 319 344 * 320 345 * Loads the .mo file in WP_LANG_DIR constant path from WordPress root. The … … 344 369 * @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 345 370 */ 346 371 function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) { 347 $locale = get_locale();372 $locale = apply_filter( 'plugin_locale', get_locale(), $domain ); 348 373 349 374 if ( false !== $plugin_rel_path ) { 350 375 $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' ); … … 366 391 * 367 392 * @param string $domain Unique identifier for retrieving translated strings 368 393 */ 369 function load_muplugin_textdomain($domain, $path = false) { 370 $locale = get_locale(); 371 if ( empty($locale) ) 372 $locale = 'en_US'; 394 function load_muplugin_textdomain( $domain ) { 395 $locale = apply_filter( 'plugin_locale', get_locale(), $domain ); 373 396 374 /* @todo $path is not used. Was it ever used and was it expected to be an arbitrary absolute dir?375 * Ideally, it should be relative to WPMU_PLUGIN_DUR.376 if ( false === $path )377 $path = WPMU_PLUGIN_DIR;378 */379 380 397 $mofile = WPMU_PLUGIN_DIR . "/$domain-$locale.mo"; 381 load_textdomain( $domain, $mofile);398 load_textdomain( $domain, $mofile ); 382 399 } 383 400 384 401 /** … … 393 410 * 394 411 * @param string $domain Unique identifier for retrieving translated strings 395 412 */ 396 function load_theme_textdomain( $domain, $path = false) {397 $locale = get_locale();413 function load_theme_textdomain( $domain, $path = false ) { 414 $locale = apply_filter( 'theme_locale', get_locale(), $domain ); 398 415 399 416 $path = ( empty( $path ) ) ? get_template_directory() : $path; 400 417 … … 414 431 * 415 432 * @param string $domain Unique identifier for retrieving translated strings 416 433 */ 417 function load_child_theme_textdomain( $domain, $path = false) {434 function load_child_theme_textdomain( $domain, $path = false ) { 418 435 $locale = get_locale(); 419 436 420 437 $path = ( empty( $path ) ) ? get_stylesheet_directory() : $path;