Gets all available languages based on the presence of *.mo and *.l10n.php files in a given directory.
The default directory is WP_LANG_DIR.
$dirstringoptional
Default:null
}
}
/**
* 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;
| 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. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_available_languages