Theme Translations: Allow for theme pomo files to be loaded from WP_LANG_DIR/themes/{$domain}-{$locale}.(p|m)o.

This directory format is what we have chosen for Language Packs (See #18200), but which is currently delayed.

By making this change, we can ship localised theme files within core for bundled themes, and avoid the issues associated with Theme Updates overwriting/removing the language files.

Fixes #18960



git-svn-id: http://core.svn.wordpress.org/trunk@22346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2012-10-31 21:30:33 +00:00
parent 41c2935278
commit 57785c7fea
1 changed files with 12 additions and 8 deletions

View File

@ -459,9 +459,16 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
function load_theme_textdomain( $domain, $path = false ) {
$locale = apply_filters( 'theme_locale', get_locale(), $domain );
$path = ( empty( $path ) ) ? get_template_directory() : $path;
if ( ! $path )
$path = get_template_directory();
$mofile = "$path/$locale.mo";
// Load the textdomain from the Theme provided location, or theme directory first
$mofile = "{$path}/{$locale}.mo";
if ( $loaded = load_textdomain($domain, $mofile) )
return $loaded;
// Else, load textdomain from the Language directory
$mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
return load_textdomain($domain, $mofile);
}
@ -478,12 +485,9 @@ function load_theme_textdomain( $domain, $path = false ) {
* @param string $domain Unique identifier for retrieving translated strings
*/
function load_child_theme_textdomain( $domain, $path = false ) {
$locale = apply_filters( 'theme_locale', get_locale(), $domain );
$path = ( empty( $path ) ) ? get_stylesheet_directory() : $path;
$mofile = "$path/$locale.mo";
return load_textdomain($domain, $mofile);
if ( ! $path )
$path = get_stylesheet_directory();
return load_theme_textdomain( $domain, $path );
}
/**