get_available_languages( string $dir = null ): string[]

In this article

Gets all available languages based on the presence of *.mo and *.l10n.php files in a given directory.

Description

The default directory is WP_LANG_DIR.

Parameters

$dirstringoptional
A directory to search for language files.
Default WP_LANG_DIR.

Default:null

Return

string[] An array of language codes or an empty array if no languages are present.
Language codes are formed by stripping the file extension from the language file names.

Source

		}
	}

	/**
	 * Filters the list of available language codes.
	 *
	 * @since 4.7.0
	 *
	 * @param string[] $languages An array of available language codes.
	 * @param string   $dir       The directory where the language files were found.
	 */
	return apply_filters( 'get_available_languages', array_unique( $languages ), $dir );
}

/**
 * Gets installed translations.
 *
 * Looks in the wp-content/languages directory for translations of
 * plugins or themes.
 *
 * @since 3.7.0
 *
 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
 *
 * @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
 * @return array Array of language data.
 */
function wp_get_installed_translations( $type ) {
	global $wp_textdomain_registry;

Changelog

VersionDescription
6.5.0The initial file list is now cached and also takes into account *.l10n.php files.
4.7.0The results are now filterable with the 'get_available_languages' filter.
3.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.