# determine_locale()

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

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

## Сигнатура

```php
determine_locale(): string
```

## Описание

Определяет текущую локаль, требуемую для запроса.

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

`string`

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

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

```php
function determine_locale() {
	/**
	 * Filters the locale for the current request prior to the default determination process.
	 *
	 * Using this filter allows to override the default logic, effectively short-circuiting the function.
	 *
	 * @since 5.0.0
	 *
	 * @param string|null $locale The locale to return and short-circuit. Default null.
	 */
	$determined_locale = apply_filters( 'pre_determine_locale', null );

	if ( $determined_locale && is_string( $determined_locale ) ) {
		return $determined_locale;
	}

	if (
		isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] &&
		( ! empty( $_GET['wp_lang'] ) || ! empty( $_COOKIE['wp_lang'] ) )
	) {
		if ( ! empty( $_GET['wp_lang'] ) ) {
			$determined_locale = sanitize_locale_name( $_GET['wp_lang'] );
		} else {
			$determined_locale = sanitize_locale_name( $_COOKIE['wp_lang'] );
		}
	} elseif (
		is_admin() ||
		( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() )
	) {
		$determined_locale = get_user_locale();
	} elseif (
		( ! empty( $_REQUEST['language'] ) || isset( $GLOBALS['wp_local_package'] ) )
		&& wp_installing()
	) {
		if ( ! empty( $_REQUEST['language'] ) ) {
			$determined_locale = sanitize_locale_name( $_REQUEST['language'] );
		} else {
			$determined_locale = $GLOBALS['wp_local_package'];
		}
	}

	if ( ! $determined_locale ) {
		$determined_locale = get_locale();
	}

	/**
	 * Filters the locale for the current request.
	 *
	 * @since 5.0.0
	 *
	 * @param string $determined_locale The locale.
	 */
	return apply_filters( 'determine_locale', $determined_locale );
}
```

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

- 5.0.0 — Introduced.

## Связанные

Использует: [`sanitize_locale_name`](https://chugunov.pro/api-wordpress/functions/sanitize_locale_name/), [`wp_is_json_request`](https://chugunov.pro/api-wordpress/functions/wp_is_json_request/), [`get_user_locale`](https://chugunov.pro/api-wordpress/functions/get_user_locale/), [`wp_installing`](https://chugunov.pro/api-wordpress/functions/wp_installing/), [`get_locale`](https://chugunov.pro/api-wordpress/functions/get_locale/), [`is_admin`](https://chugunov.pro/api-wordpress/functions/is_admin/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`_load_script_textdomain_from_src`](https://chugunov.pro/api-wordpress/functions/_load_script_textdomain_from_src/), `WP_REST_Site_Health_Controller::load_admin_textdomain`, [`_get_path_to_translation_from_lang_dir`](https://chugunov.pro/api-wordpress/functions/_get_path_to_translation_from_lang_dir/), `WP_Locale_Switcher::switch_to_locale`, `WP_Locale_Switcher::__construct`, [`_load_textdomain_just_in_time`](https://chugunov.pro/api-wordpress/functions/_load_textdomain_just_in_time/), [`login_footer`](https://chugunov.pro/api-wordpress/functions/login_footer/), [`load_textdomain`](https://chugunov.pro/api-wordpress/functions/load_textdomain/), [`load_default_textdomain`](https://chugunov.pro/api-wordpress/functions/load_default_textdomain/), [`get_bloginfo`](https://chugunov.pro/api-wordpress/functions/get_bloginfo/), [`wp_default_scripts`](https://chugunov.pro/api-wordpress/functions/wp_default_scripts/).

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