_nx

SummerySummery

Translates and retrieves the singular or plural form based on the supplied number, with gettext context.

Syntax

_nx( string $single, string $plural, int $number, string $context, string $domain = 'default' )

DescriptionDescription

This is a hybrid of _n() and _x(). It supports context and plurals.

Used when you want to use the appropriate form of a string with context based on whether a number is singular or plural.

Example of a generic phrase which is disambiguated via the context parameter:

printf( _nx( '%s group', '%s groups', $people, 'group of people', 'text-domain' ), number_format_i18n( $people ) );
printf( _nx( '%s group', '%s groups', $animals, 'group of animals', 'text-domain' ), number_format_i18n( $animals ) );

ParametersParameters

$single

(string) (Required) The text to be used if the number is singular.

$plural

(string) (Required) The text to be used if the number is plural.

$number

(int) (Required) The number to compare against to use either the singular or plural form.

$context

(string) (Required) Context information for the translators.

$domain

(string) (Optional) Text domain. Unique identifier for retrieving translated strings.

Default value: 'default'

ReturnReturn

(string) The translated singular or plural form.

SourceSource

File: wp-includes/l10n.php


			

ChangelogChangelog

Changelog
Version Description
2.8.0 Introduced.
Scroll to Top