mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-11 22:29:48 +01:00
Allow plugins to override the behaviour of load_textdomain() in a variety of flexible ways. Fixes #11012 props johanee and nbachiyski.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d2fa378957
commit
5994455911
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user