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
$dir
stringoptional- A directory to search for language files.
Default WP_LANG_DIR.Default:
null
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
Version | Description |
---|---|
6.5.0 | The initial file list is now cached and also takes into account *.l10n.php files. |
4.7.0 | The results are now filterable with the 'get_available_languages' filter. |
3.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.