Perform a language translation with singular and plural versions

Please note this method is and thus not intended to be called directly.

Example

$items = array(...);
$qty = count($items);
echo _n('Found one item', 'Found multiple items', $qty);
echo sprintf(_n('Found one item', 'Found %d items', $qty), $qty);

Internal usage

// basic internal usage
$string = _n(string $textSingular, string $textPlural, int $count);

// internal usage with all arguments
$string = _n(string $textSingular, string $textPlural, int $count, string $textdomain = null);

Arguments

NameType(s)Description
$textSingularstring

Singular version of text (when there is 1 item)

$textPluralstring

Plural version of text (when there are multiple items or 0 items)

$countint

Quantity of items, should be 0 or more.

$textdomain (optional)string

Textdomain for the text, may be class name, filename, or something made up by you. If omitted, a debug backtrace will attempt to determine automatically.

Return value

string

Translated text or original text if translation not available.

See Also


Functions methods and properties

API reference based on ProcessWire core version 3.0.251