CoolCMS API

CurrencyUnitFormatter
in package

FinalYes

Builds the unit after an amount from the currency translation ({@see \App\Core\Base\Shared\System\Models\Entities\CurrencyText}::getUnitLabel) for the current language and pluralizes it by count. `unit_label` is a Symfony interval/plural pattern, e.g. `{0}credits|[1,4]credit|[5,Inf]credits`.

Pluralization runs through IdentityTranslator, which formats the pattern itself without a catalog; the Contributte translator would honor returnOriginalMessage and return the pattern unexpanded.

Returns null when the currency has no translation or unit_label for the language; the caller (priceFormat) then falls back to the currency abbreviation.

Table of Contents

Properties

$pluralizer  : IdentityTranslator

Methods

__construct()  : mixed
resolve()  : string|null

Properties

Methods

resolve()

public resolve(object|null $currency, float|int $amount, int|string|null $langId) : string|null
Parameters
$currency : object|null

currency with translations (getTranslation(langId)->getUnitLabel())

$amount : float|int

count for pluralization (the amount value)

$langId : int|string|null

id of the current language (CurrencyText.languageId)

Return values
string|null
On this page

Search results