Allow plugins to override the behaviour of load_textdomain() in a variety of flexible ways. Fixes #11012 props johanee and nbachiyski.

git-svn-id: https://develop.svn.wordpress.org/trunk@12251 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2009-11-21 09:28:32 +00:00
parent 69422cfa9c
commit 6b92317f98
1 changed files with 28 additions and 18 deletions

View File

@ -80,7 +80,6 @@ function before_last_bar( $string ) {
*/
function translate_with_context( $text, $domain = 'default' ) {
return before_last_bar( translate( $text, $domain ) );
}
function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
@ -323,6 +322,16 @@ function _nx_noop( $single, $plural, $context ) {
function load_textdomain( $domain, $mofile ) {
global $l10n;
$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
if ( true == $plugin_override ) {
return true;
}
do_action( 'load_textdomain', $domain, $mofile );
$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
if ( !is_readable( $mofile ) ) return false;
$mo = new MO();
@ -332,6 +341,7 @@ function load_textdomain($domain, $mofile) {
$mo->merge_with( $l10n[$domain] );
$l10n[$domain] = &$mo;
return true;
}