# _n()

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

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

## Сигнатура

```php
_n( string $single, string $plural, int $number, string $domain = 'default' ): string
```

## Описание

Используется, когда нужно выбрать подходящую форму строки в зависимости от того, единственное это число или множественное.
Пример:
printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) );

## Параметры

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

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

`string`

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

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

```php
function _n( $single, $plural, $number, $domain = 'default' ) {
	$translations = get_translations_for_domain( $domain );
	$translation  = $translations->translate_plural( $single, $plural, $number );

	/**
	 * Filters the singular or plural form of a string.
	 *
	 * @since 2.2.0
	 *
	 * @param string $translation Translated text.
	 * @param string $single      The text to be used if the number is singular.
	 * @param string $plural      The text to be used if the number is plural.
	 * @param int    $number      The number to compare against to use either the singular or plural form.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
	$translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );

	/**
	 * Filters the singular or plural form of a string 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 $single      The text to be used if the number is singular.
	 * @param string $plural      The text to be used if the number is plural.
	 * @param int    $number      The number to compare against to use either the singular or plural form.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
	$translation = apply_filters( "ngettext_{$domain}", $translation, $single, $plural, $number, $domain );

	return $translation;
}
```

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

- 5.5.0 — Introduced ngettext-{$domain} filter.
- 2.8.0 — Introduced.

## Связанные

Использует: [`get_translations_for_domain`](https://chugunov.pro/api-wordpress/functions/get_translations_for_domain/), `Translations::translate_plural`, [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: `WP_Site_Health::get_test_page_cache`, [`rest_validate_object_value_from_schema`](https://chugunov.pro/api-wordpress/functions/rest_validate_object_value_from_schema/), [`rest_validate_array_value_from_schema`](https://chugunov.pro/api-wordpress/functions/rest_validate_array_value_from_schema/), [`rest_validate_string_value_from_schema`](https://chugunov.pro/api-wordpress/functions/rest_validate_string_value_from_schema/), [`wp_dashboard_site_health`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_site_health/), `WP_Site_Health::get_test_plugin_version`, `WP_Site_Health::get_test_theme_version`, [`validate_plugin_requirements`](https://chugunov.pro/api-wordpress/functions/validate_plugin_requirements/), [`human_readable_duration`](https://chugunov.pro/api-wordpress/functions/human_readable_duration/), `WP_Privacy_Requests_Table::process_bulk_action`, `WP_Widget_Custom_HTML::enqueue_admin_scripts`, `WP_Customize_Manager::save_changeset_post`, [`print_embed_comments_button`](https://chugunov.pro/api-wordpress/functions/print_embed_comments_button/), `WP_Customize_Nav_Menus::enqueue_scripts`, `WP_Customize_Nav_Menus::customize_register`, [`get_comments_number_text`](https://chugunov.pro/api-wordpress/functions/get_comments_number_text/), `WP_MS_Users_List_Table::get_views`, `WP_Screen::render_screen_layout`, `WP_Plugins_List_Table::get_views`, `WP_List_Table::ajax_response`, `WP_List_Table::comments_bubble`, `WP_List_Table::pagination`, `WP_MS_Themes_List_Table::get_views`, [`install_plugin_information`](https://chugunov.pro/api-wordpress/functions/install_plugin_information/), [`wp_dashboard_right_now`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_right_now/), [`wp_network_dashboard_right_now`](https://chugunov.pro/api-wordpress/functions/wp_network_dashboard_right_now/), [`wp_star_rating`](https://chugunov.pro/api-wordpress/functions/wp_star_rating/), `WP_Users_List_Table::single_row`, [`_wp_ajax_delete_comment_response`](https://chugunov.pro/api-wordpress/functions/_wp_ajax_delete_comment_response/), [`wp_ajax_replyto_comment`](https://chugunov.pro/api-wordpress/functions/wp_ajax_replyto_comment/), [`translate_nooped_plural`](https://chugunov.pro/api-wordpress/functions/translate_nooped_plural/), [`_n_noop`](https://chugunov.pro/api-wordpress/functions/_n_noop/), [`_nx_noop`](https://chugunov.pro/api-wordpress/functions/_nx_noop/), [`human_time_diff`](https://chugunov.pro/api-wordpress/functions/human_time_diff/), [`wp_notify_moderator`](https://chugunov.pro/api-wordpress/functions/wp_notify_moderator/), [`__ngettext`](https://chugunov.pro/api-wordpress/functions/__ngettext/), [`_nc`](https://chugunov.pro/api-wordpress/functions/_nc/), [`_n`](https://chugunov.pro/api-wordpress/functions/_n/), [`wp_get_update_data`](https://chugunov.pro/api-wordpress/functions/wp_get_update_data/), [`wp_admin_bar_comments_menu`](https://chugunov.pro/api-wordpress/functions/wp_admin_bar_comments_menu/).

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