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¶
$plural¶
Message string. Might use replacements like %foo%, which are replaced by the values specified in the values array.
|
|
$singular¶
Singular string. Might use replacements like %foo%, which are replaced by the values specified in the values array.
|
|
$values¶
Translation value objects.
|
|
Methods¶
__construct() ¶
Construct plural message from singular, plural and value array.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$singular | string | - | - |
$plural | string | - | - |
$values | array<string, scalar> | - | - |
__toString() ¶
|
|
getProperties() ¶
Function where list of properties are returned.
|
|
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>