WordPress.org

Make WordPress Core

Changeset 22346


Ignore:
Timestamp:
10/31/12 21:30:33 (18 months ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/l10n.php

    r22113 r22346  
    460460    $locale = apply_filters( 'theme_locale', get_locale(), $domain ); 
    461461 
    462     $path = ( empty( $path ) ) ? get_template_directory() : $path; 
    463  
    464     $mofile = "$path/$locale.mo"; 
     462    if ( ! $path ) 
     463        $path = get_template_directory(); 
     464 
     465    // Load the textdomain from the Theme provided location, or theme directory first 
     466    $mofile = "{$path}/{$locale}.mo"; 
     467    if ( $loaded = load_textdomain($domain, $mofile) ) 
     468        return $loaded; 
     469 
     470    // Else, load textdomain from the Language directory 
     471    $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo"; 
    465472    return load_textdomain($domain, $mofile); 
    466473} 
     
    479486 */ 
    480487function load_child_theme_textdomain( $domain, $path = false ) { 
    481     $locale = apply_filters( 'theme_locale', get_locale(), $domain ); 
    482  
    483     $path = ( empty( $path ) ) ? get_stylesheet_directory() : $path; 
    484  
    485     $mofile = "$path/$locale.mo"; 
    486     return load_textdomain($domain, $mofile); 
     488    if ( ! $path ) 
     489        $path = get_stylesheet_directory(); 
     490    return load_theme_textdomain( $domain, $path ); 
    487491} 
    488492 
Note: See TracChangeset for help on using the changeset viewer.