CoolCMS API

PluralTextFormatter
in package

FinalYes

Resolves the display text of a parameter value according to a count.

The text is either plain (a unit such as m²) or a plural template in the same format as the project translations (NEON):

{1}day|[2,4]days|[5,Inf]days

The variant is chosen by %count% in $parameters (must be numeric) through the Symfony IdentityTranslator, the same engine that resolves plurals in translation keys. With explicit intervals ({1}, [2,4], ...) the choice does not depend on the language. Other placeholders (%value%, %value2%, ...) are only substituted; a text without them is returned as the chosen variant unchanged.

Table of Contents

Properties

$translator  : IdentityTranslator|null

Methods

format()  : string
translator()  : IdentityTranslator

Properties

Methods

format()

public static format(string|null $text[, array<string, string|int> $parameters = [] ][, string $locale = 'cs' ]) : string
Parameters
$text : string|null
$parameters : array<string, string|int> = []

named replacements; the plural is chosen by %count% when it is numeric.

$locale : string = 'cs'
Return values
string

translator()

private static translator() : IdentityTranslator
Return values
IdentityTranslator
On this page

Search results