# get_available_languages()

URL: https://chugunov.pro/api-wordpress/functions/get_available_languages/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.0.0.

## Сигнатура

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

## Описание

Каталог по умолчанию — WP_LANG_DIR.

## Параметры

- `$dir` `string` — необязательный, по умолчанию `null`. Каталог для поиска языковых файлов.
  
  По умолчанию WP_LANG_DIR.

## Возвращаемое значение

`string[]`

## Исходный код

Файл: `wp-includes/l10n.php:1552`

```php
function get_available_languages( $dir = null ) {
	global $wp_textdomain_registry;

	$languages = array();

	$path       = $dir ?? WP_LANG_DIR;
	$lang_files = $wp_textdomain_registry->get_language_files_from_path( $path );

	if ( $lang_files ) {
		foreach ( $lang_files as $lang_file ) {
			$lang_file = basename( $lang_file, '.mo' );
			$lang_file = basename( $lang_file, '.l10n.php' );

			if ( ! str_starts_with( $lang_file, 'continents-cities' ) && ! str_starts_with( $lang_file, 'ms-' ) &&
				! str_starts_with( $lang_file, 'admin-' ) ) {
				$languages[] = $lang_file;
			}
		}
	}

	/**
	 * 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 );
}
```

## История изменений

- 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.

## Связанные

Использует: `WP_Textdomain_Registry::get_language_files_from_path`, [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: `WP_REST_Plugins_Controller::create_item`, `WP_REST_Users_Controller::get_item_schema`, `WP_Locale_Switcher::__construct`, [`signup_get_available_languages`](https://chugunov.pro/api-wordpress/functions/signup_get_available_languages/), [`wp_install_language_form`](https://chugunov.pro/api-wordpress/functions/wp_install_language_form/), [`wp_download_language_pack`](https://chugunov.pro/api-wordpress/functions/wp_download_language_pack/), [`login_footer`](https://chugunov.pro/api-wordpress/functions/login_footer/), [`edit_user`](https://chugunov.pro/api-wordpress/functions/edit_user/), [`sanitize_option`](https://chugunov.pro/api-wordpress/functions/sanitize_option/), [`wp_update_plugins`](https://chugunov.pro/api-wordpress/functions/wp_update_plugins/), [`wp_update_themes`](https://chugunov.pro/api-wordpress/functions/wp_update_themes/), [`register_new_user`](https://chugunov.pro/api-wordpress/functions/register_new_user/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/get_available_languages/
