# translate()

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

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

## Сигнатура

```php
translate( string $text, string $domain = 'default' ): string
```

## Описание

Если перевода нет или текстовый домен не загружен, возвращается исходный текст.
_Примечание:_ Не используйте translate() напрямую, используйте __() или связанные функции.

## Параметры

- `$text` `string` — обязательный. Текст для перевода.
- `$domain` `string` — необязательный, по умолчанию `'default'`. Текстовый домен. Уникальный идентификатор для получения переведённых строк.
  
  Значение по умолчанию: 'default'.

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

`string`

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

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

```php
function translate( $text, $domain = 'default' ) {
	$translations = get_translations_for_domain( $domain );
	$translation  = $translations->translate( $text );

	/**
	 * Filters text with its translation.
	 *
	 * @since 2.0.11
	 *
	 * @param string $translation Translated text.
	 * @param string $text        Text to translate.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
	$translation = apply_filters( 'gettext', $translation, $text, $domain );

	/**
	 * Filters text with its translation for a domain.
	 *
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
	 *
	 * @since 5.5.0
	 *
	 * @param string $translation Translated text.
	 * @param string $text        Text to translate.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
	$translation = apply_filters( "gettext_{$domain}", $translation, $text, $domain );

	return $translation;
}
```

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

- 5.5.0 — Introduced gettext-{$domain} filter.
- 2.2.0 — Introduced.

## Связанные

Использует: [`get_translations_for_domain`](https://chugunov.pro/api-wordpress/functions/get_translations_for_domain/), `Translations::translate`, [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`wp_credits_section_title`](https://chugunov.pro/api-wordpress/functions/wp_credits_section_title/), [`wp_credits_section_list`](https://chugunov.pro/api-wordpress/functions/wp_credits_section_list/), [`_get_plugin_data_markup_translate`](https://chugunov.pro/api-wordpress/functions/_get_plugin_data_markup_translate/), [`wp_get_popular_importers`](https://chugunov.pro/api-wordpress/functions/wp_get_popular_importers/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_attr__`](https://chugunov.pro/api-wordpress/functions/esc_attr__/), [`esc_html__`](https://chugunov.pro/api-wordpress/functions/esc_html__/), [`_e`](https://chugunov.pro/api-wordpress/functions/_e/), [`esc_attr_e`](https://chugunov.pro/api-wordpress/functions/esc_attr_e/), [`esc_html_e`](https://chugunov.pro/api-wordpress/functions/esc_html_e/), [`_c`](https://chugunov.pro/api-wordpress/functions/_c/), [`translate_with_context`](https://chugunov.pro/api-wordpress/functions/translate_with_context/), [`translate`](https://chugunov.pro/api-wordpress/functions/translate/), `WP_Theme::translate_header`, [`wp_timezone_choice`](https://chugunov.pro/api-wordpress/functions/wp_timezone_choice/).

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