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

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


git-svn-id: http://core.svn.wordpress.org/trunk@25569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin
2013-09-30 19:47:12 +00:00
parent 55822259df
commit ddd4473714
2 changed files with 24 additions and 8 deletions

View File

@@ -745,17 +745,22 @@ function get_available_languages( $dir = null ) {
*
* @since 3.7.0
*
* @param string $type What to search for. Accepts 'plugins', 'themes'.
* @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
* @return array Array of language data.
*/
function wp_get_installed_translations( $type ) {
if ( $type !== 'themes' && $type !== 'plugins' )
if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' )
return array();
if ( ! is_dir( WP_LANG_DIR ) || ! is_dir( WP_LANG_DIR . "/$type" ) )
$dir = 'core' === $type ? '' : "/$type";
if ( ! is_dir( WP_LANG_DIR ) )
return array();
$files = scandir( WP_LANG_DIR . "/$type" );
if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) )
return array();
$files = scandir( WP_LANG_DIR . $dir );
if ( ! $files )
return array();
@@ -766,11 +771,13 @@ function wp_get_installed_translations( $type ) {
continue;
if ( substr( $file, -3 ) !== '.po' )
continue;
if ( ! preg_match( '/(.*)-([A-Za-z_]{2,6}).po/', $file, $match ) )
if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) )
continue;
list( , $textdomain, $language ) = $match;
$language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "/$type/$file" );
if ( '' === $textdomain )
$textdomain = 'default';
$language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
}
return $language_data;
}