_nx_noop()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
_nx_noop( string $singular, string $plural, string $context, string $domain = null ): array
Описание
Используется, когда нужно сохранить структуры с переводимыми строками во множественном числе и использовать их позже, когда число станет известно.
Пример обобщённой фразы, которая уточняется через параметр контекста:
$messages = array(
'people' => _nx_noop( '%s group', '%s groups', 'people', 'text-domain' ),
'animals' => _nx_noop( '%s group', '%s groups', 'animals', 'text-domain' ),
);
...
$message = $messages[ $type ];
printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );
Оригинал (английский)
Used when you want to keep structures with translatable plural strings and use them later when the number is known.
Example of a generic phrase which is disambiguated via the context parameter:
$messages = array(
'people' => _nx_noop( '%s group', '%s groups', 'people', 'text-domain' ),
'animals' => _nx_noop( '%s group', '%s groups', 'animals', 'text-domain' ),
);
...
$message = $messages[ $type ];
printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );
Параметры
$singular
string
обязательный
$plural
string
обязательный
$context
string
обязательный
$domain
string
необязательный
= null
Возвращаемое значение
array
Исходный код
wp-includes/l10n.php:654
function _nx_noop( $singular, $plural, $context, $domain = null ) {
return array(
0 => $singular,
1 => $plural,
2 => $context,
'singular' => $singular,
'plural' => $plural,
'context' => $context,
'domain' => $domain,
);
}
История изменений
| Версия | Описание |
|---|---|
| 2.8.0 | Introduced. |

