# get_locale()

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

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

## Сигнатура

```php
get_locale(): string
```

## Описание

Если локаль задана, она фильтруется через хук-фильтр ‘locale’ и возвращается её значение.
Если локаль ещё не задана, используется константа WPLANG, если она определена. Затем значение фильтруется через хук-фильтр ‘locale’, устанавливается глобальная переменная локали и локаль возвращается.
Процесс получения локали должен выполняться только один раз, но локаль всегда фильтруется через хук ‘locale’.

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

`string` — 'locale'

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

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

```php
function get_locale() {
	global $locale, $wp_local_package;

	if ( isset( $locale ) ) {
		/** This filter is documented in wp-includes/l10n.php */
		return apply_filters( 'locale', $locale );
	}

	if ( isset( $wp_local_package ) ) {
		$locale = $wp_local_package;
	}

	// WPLANG was defined in wp-config.
	if ( defined( 'WPLANG' ) ) {
		$locale = WPLANG;
	}

	// If multisite, check options.
	if ( is_multisite() ) {
		// Don't check blog option when installing.
		if ( wp_installing() ) {
			$ms_locale = get_site_option( 'WPLANG' );
		} else {
			$ms_locale = get_option( 'WPLANG' );
			if ( false === $ms_locale ) {
				$ms_locale = get_site_option( 'WPLANG' );
			}
		}

		if ( false !== $ms_locale ) {
			$locale = $ms_locale;
		}
	} else {
		$db_locale = get_option( 'WPLANG' );
		if ( false !== $db_locale ) {
			$locale = $db_locale;
		}
	}

	if ( empty( $locale ) ) {
		$locale = 'en_US';
	}

	/**
	 * Filters the locale ID of the WordPress installation.
	 *
	 * @since 1.5.0
	 *
	 * @param string $locale The locale ID.
	 */
	return apply_filters( 'locale', $locale );
}
```

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

- 1.5.0 — Introduced.

## Связанные

Использует: [`wp_installing`](https://chugunov.pro/api-wordpress/functions/wp_installing/), [`is_multisite`](https://chugunov.pro/api-wordpress/functions/is_multisite/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_site_option`](https://chugunov.pro/api-wordpress/functions/get_site_option/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: [`wp_get_image_alttext`](https://chugunov.pro/api-wordpress/functions/wp_get_image_alttext/), `WP_Debug_Data::get_wp_core`, [`wpmu_new_site_admin_notification`](https://chugunov.pro/api-wordpress/functions/wpmu_new_site_admin_notification/), `WP_Automatic_Updater::send_plugin_theme_email`, `WP_Recovery_Mode_Email_Service::send_recovery_mode_email`, [`populate_network_meta`](https://chugunov.pro/api-wordpress/functions/populate_network_meta/), [`determine_locale`](https://chugunov.pro/api-wordpress/functions/determine_locale/), [`_wp_privacy_send_erasure_fulfillment_notification`](https://chugunov.pro/api-wordpress/functions/_wp_privacy_send_erasure_fulfillment_notification/), [`wp_send_user_request`](https://chugunov.pro/api-wordpress/functions/wp_send_user_request/), [`wp_privacy_send_personal_data_export_email`](https://chugunov.pro/api-wordpress/functions/wp_privacy_send_personal_data_export_email/), [`get_user_locale`](https://chugunov.pro/api-wordpress/functions/get_user_locale/), [`wp_maybe_decline_date`](https://chugunov.pro/api-wordpress/functions/wp_maybe_decline_date/), [`translations_api`](https://chugunov.pro/api-wordpress/functions/translations_api/), [`login_header`](https://chugunov.pro/api-wordpress/functions/login_header/), `WP_Automatic_Updater::send_email`, `WP_Automatic_Updater::send_debug_email`, [`insert_with_markers`](https://chugunov.pro/api-wordpress/functions/insert_with_markers/), [`list_core_update`](https://chugunov.pro/api-wordpress/functions/list_core_update/), [`list_translation_updates`](https://chugunov.pro/api-wordpress/functions/list_translation_updates/), [`get_locale_stylesheet_uri`](https://chugunov.pro/api-wordpress/functions/get_locale_stylesheet_uri/), [`remove_accents`](https://chugunov.pro/api-wordpress/functions/remove_accents/), [`wp_password_change_notification`](https://chugunov.pro/api-wordpress/functions/wp_password_change_notification/), [`wp_new_user_notification`](https://chugunov.pro/api-wordpress/functions/wp_new_user_notification/), [`wp_notify_postauthor`](https://chugunov.pro/api-wordpress/functions/wp_notify_postauthor/), [`wp_notify_moderator`](https://chugunov.pro/api-wordpress/functions/wp_notify_moderator/), [`wp_timezone_choice`](https://chugunov.pro/api-wordpress/functions/wp_timezone_choice/), [`wp_version_check`](https://chugunov.pro/api-wordpress/functions/wp_version_check/).

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