Get all available languages based on the presence of *.mo files in a given directory.

The default directory is WP_LANG_DIR.

Signature

get_available_languages( $dir = null )
dir
 (string) A directory to search for language files. Default WP_LANG_DIR.
Default: null

Return

(array) An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.

Source

function get_available_languages( $dir = null ) {
	$languages = array();

	foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
		$lang_file = basename($lang_file, '.mo');
		if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
			0 !== strpos( $lang_file, 'admin-' ))
			$languages[] = $lang_file;
	}

	return $languages;
}
WP Trac GitHub

Link here