Allow for plugin translations to be loaded from WP_LANG_DIR/plugins/$domain-$locale.mo.

props dimadin.
see #18200.


Built from https://develop.svn.wordpress.org/trunk@25059


git-svn-id: http://core.svn.wordpress.org/trunk@25045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-08-20 12:34:09 +00:00
parent 7317940591
commit d6b7c9ccc8
1 changed files with 21 additions and 7 deletions

View File

@ -447,7 +447,13 @@ function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_pat
$path = WP_PLUGIN_DIR;
}
$mofile = $path . '/'. $domain . '-' . $locale . '.mo';
// Load the textdomain according to the plugin first
$mofile = $domain . '-' . $locale . '.mo';
if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) )
return $loaded;
// Otherwise, load from the languages directory
$mofile = WP_LANG_DIR . '/plugins/' . $mofile;
return load_textdomain( $domain, $mofile );
}
@ -462,8 +468,16 @@ function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_pat
*/
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
load_textdomain( $domain, trailingslashit( $path ) . "$domain-$locale.mo" );
$path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
// Load the textdomain according to the plugin first
$mofile = $domain . '-' . $locale . '.mo';
if ( $loaded = load_textdomain( $domain, $path . $mofile ) )
return $loaded;
// Otherwise, load from the languages directory
$mofile = WP_LANG_DIR . '/plugins/' . $mofile;
return load_textdomain( $domain, $mofile );
}
/**
@ -484,12 +498,12 @@ function load_theme_textdomain( $domain, $path = false ) {
if ( ! $path )
$path = get_template_directory();
// Load the textdomain from the Theme provided location, or theme directory first
// Load the textdomain according to the theme
$mofile = "{$path}/{$locale}.mo";
if ( $loaded = load_textdomain( $domain, $mofile ) )
return $loaded;
// Else, load textdomain from the Language directory
// Otherwise, load from the languages directory
$mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
return load_textdomain( $domain, $mofile );
}