Make WordPress Core

Changeset 25059


Ignore:
Timestamp:
08/20/2013 12:33:07 PM (12 years ago)
Author:
nacin
Message:

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

props dimadin.
see #18200.

File:
1 edited

Legend:

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

    r24825 r25059  
    448448    }
    449449
    450     $mofile = $path . '/'. $domain . '-' . $locale . '.mo';
     450    // Load the textdomain according to the plugin first
     451    $mofile = $domain . '-' . $locale . '.mo';
     452    if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) )
     453        return $loaded;
     454
     455    // Otherwise, load from the languages directory
     456    $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    451457    return load_textdomain( $domain, $mofile );
    452458}
     
    463469function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
    464470    $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    465     $path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
    466     load_textdomain( $domain, trailingslashit( $path ) . "$domain-$locale.mo" );
     471    $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
     472
     473    // Load the textdomain according to the plugin first
     474    $mofile = $domain . '-' . $locale . '.mo';
     475    if ( $loaded = load_textdomain( $domain, $path . $mofile ) )
     476        return $loaded;
     477
     478    // Otherwise, load from the languages directory
     479    $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
     480    return load_textdomain( $domain, $mofile );
    467481}
    468482
     
    485499        $path = get_template_directory();
    486500
    487     // Load the textdomain from the Theme provided location, or theme directory first
     501    // Load the textdomain according to the theme
    488502    $mofile = "{$path}/{$locale}.mo";
    489     if ( $loaded = load_textdomain($domain, $mofile) )
     503    if ( $loaded = load_textdomain( $domain, $mofile ) )
    490504        return $loaded;
    491505
    492     // Else, load textdomain from the Language directory
     506    // Otherwise, load from the languages directory
    493507    $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
    494     return load_textdomain($domain, $mofile);
     508    return load_textdomain( $domain, $mofile );
    495509}
    496510
Note: See TracChangeset for help on using the changeset viewer.