Copied!

Plural

Plural.php : 34
Extends Translation

Class for translatable messages, which may contain plural forms.

The message might include replacements, in the form %[A-Za-z]%. Those are replaced by the values provided. A raw % can be escaped like %%.

You need to provide a singular and plural variant for the string. The strings provided should be English and will be translated depending on the environment language.

This interface follows the interfaces of XLIFF, gettext, Symfony Translations and Zend_Translate. For singular forms you just provide a plain string (with optional placeholders without effects on the plural forms). For potential plural forms you always provide a singular variant and an English simple plural variant. An instance of this class can be cast to a string. In such case whether to use singular or plural form is determined based on the value of first element of $values array (it needs to be 1 for singular, anything else for plural). If plurality cannot be inferred from $values, a plural form is assumed as default. To force singular form, use Message instead.

No implementation supports multiple different plural forms in one single message.

The singular / plural string could, for Symfony, for example be converted to "$singular|$plural", and you would call gettext like: ngettext($singular, $plural, $count ).

Properties

protected $plural

Plural.php : 46

Message string. Might use replacements like %foo%, which are replaced by the values specified in the values array.

protected string $plural

protected $singular

Plural.php : 40

Singular string. Might use replacements like %foo%, which are replaced by the values specified in the values array.

protected string $singular

protected $values

Plural.php : 53

Translation value objects.

protected array<string, scalar> $values

Methods

public__construct()

Plural.php : 60

Construct plural message from singular, plural and value array.

public __construct(string $singular, string $plural, array<string, scalar> $values)

Parameters

Name Type Default value Description
$singular string - -
$plural string - -
$values array<string, scalar> - -

public__toString()

Plural.php : 69
public __toString() : mixed

protectedgetProperties()

ValueObject.php : 50

Function where list of properties are returned.

protected getProperties([array<string|int, mixed> $dynamicProperties = [] ]) : array<string|int, mixed>

Used by attributes(), override to add dynamic properties

Parameters

Name Type Default value Description
$dynamicProperties array<string|int, mixed> []

Additional dynamic properties exposed on the object

Return values

array<string|int, mixed>