get_available_languages( string $dir = null )
Get all available languages based on the presence of *.mo files in a given directory.
描述
The default directory is WP_LANG_DIR.
参数
- $dir
-
(string)
(Optional)
A directory to search for language files. Default WP_LANG_DIR.Default value: null
返回值
(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.
源代码
File: wp-includes/l10n.php
function get_available_languages( $dir = null ) {
$languages = array();
$lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' );
if ( $lang_files ) {
foreach ( $lang_files 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;
}
}
}
/**
* Filters the list of available language codes.
*
* @since 4.7.0
*
* @param array $languages An array of available language codes.
* @param string $dir The directory where the language files were found.
*/
return apply_filters( 'get_available_languages', $languages, $dir );
}
更新日志
Version | 描述 |
---|---|
4.7.0 | The results are now filterable with the ‘get_available_languages’ filter. |
3.0.0 | Introduced. |
相关函数
Uses
-
wp-includes/l10n.php:
get_available_languages -
wp-includes/plugin.php:
apply_filters()
Used By
-
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:
WP_REST_Users_Controller::get_item_schema() -
wp-includes/class-wp-locale-switcher.php:
WP_Locale_Switcher::__construct() -
wp-signup.php:
signup_get_available_languages() -
wp-admin/includes/translation-install.php:
wp_install_language_form() -
wp-admin/includes/translation-install.php:
wp_download_language_pack() -
wp-admin/includes/user.php:
edit_user() -
wp-includes/formatting.php:
sanitize_option() -
wp-includes/update.php:
wp_update_plugins() -
wp-includes/update.php:
wp_update_themes()
Show 4 more used by
Hide more used by
你可能对这些文章感兴趣:
- wordpress函数get_the_posts_navigation()用法示例
- wordpress函数get_the_title()用法示例
- wordpress函数get_the_terms()用法示例
- wordpress函数get_the_tags()用法示例
- wordpress函数get_the_taxonomies()用法示例
- wordpress函数get_the_permalink()用法示例
- wordpress函数get_the_password_form()用法示例
- wordpress函数get_the_posts_pagination()用法示例
- wordpress函数get_the_modified_date()用法示例
- wordpress函数get_the_modified_time()用法示例
- wordpress函数get_the_modified_author()用法示例
- wordpress函数get_the_guid()用法示例
- wordpress函数get_the_ID()用法示例
- wordpress函数get_the_excerpt()用法示例
如有疑问,请前往问答中心反馈!
反馈