Make WordPress Core


Ignore:
Timestamp:
09/30/2013 07:46:15 PM (12 years ago)
Author:
nacin
Message:

Send back core translation information to the API. Update wp_get_installed_translations() to work with core translations. see #18200.

File:
1 edited

Legend:

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

    r25586 r25652  
    746746 * @since 3.7.0
    747747 *
    748  * @param string $type What to search for. Accepts 'plugins', 'themes'.
     748 * @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
    749749 * @return array Array of language data.
    750750 */
    751751function wp_get_installed_translations( $type ) {
    752     if ( $type !== 'themes' && $type !== 'plugins' )
     752    if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' )
    753753        return array();
    754754
    755     if ( ! is_dir( WP_LANG_DIR ) || ! is_dir( WP_LANG_DIR . "/$type" ) )
     755    $dir = 'core' === $type ? '' : "/$type";
     756
     757    if ( ! is_dir( WP_LANG_DIR ) )
    756758        return array();
    757759
    758     $files = scandir( WP_LANG_DIR . "/$type" );
     760    if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) )
     761        return array();
     762
     763    $files = scandir( WP_LANG_DIR . $dir );
    759764    if ( ! $files )
    760765        return array();
     
    767772        if ( substr( $file, -3 ) !== '.po' )
    768773            continue;
    769         if ( ! preg_match( '/(.*)-([A-Za-z_]{2,6}).po/', $file, $match ) )
     774        if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) )
    770775            continue;
    771776
    772777        list( , $textdomain, $language ) = $match;
    773         $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "/$type/$file" );
     778        if ( '' === $textdomain )
     779            $textdomain = 'default';
     780        $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
    774781    }
    775782    return $language_data;
Note: See TracChangeset for help on using the changeset viewer.