Helper for rendering text based on a count number (like the I18n plural translation helper, but when translation is not needed).

Please note that we did not write any hard-coded rules for languages, as languages can evolve, we preferred to let the developer define the rules himself, instead of potentially break applications if we change rules in the future.

However, you can find most of the up-to-date plural rules for most languages in those links:

package Default
inherited_from \Zend\View\Helper\AbstractHelper

 Methods

__construct()

__construct() 

Exceptions

\Zend\I18n\Exception\ExtensionNotLoadedException if ext/intl is not present

Given an array of strings, a number and, if wanted, an optional locale (the default one is used otherwise), this picks the right string according to plural rules of the locale

__invoke(array|string $strings, integer $number) : string

Parameters

$strings

arraystring

$number

integer

Exceptions

\Zend\I18n\Exception\InvalidArgumentException

Returns

string

Get the plural rule to use

getPluralRule() : \Zend\I18n\Translator\Plural\Rule

Returns

\Zend\I18n\Translator\Plural\Rule

Get the view object

getView() : null | \Zend\View\Renderer\RendererInterface
Inherited
inherited_from \Zend\View\Helper\HelperInterface::getView()

Returns

null\Zend\View\Renderer\RendererInterface

Set the plural rule to use

setPluralRule(\Zend\I18n\Translator\Plural\Rule|string $pluralRule) : \Zend\I18n\View\Helper\Plural

Parameters

$pluralRule

\Zend\I18n\Translator\Plural\Rulestring

Returns

\Zend\I18n\View\Helper\Plural

Set the View object

setView(\Zend\View\Renderer\RendererInterface $view) : \Zend\View\Helper\AbstractHelper
Inherited
inherited_from \Zend\View\Helper\HelperInterface::setView()

Parameters

$view

\Zend\View\Renderer\RendererInterface

Returns

\Zend\View\Helper\AbstractHelper

 Properties

 

Plural rule to use

$rule : \Zend\I18n\Translator\Plural\Rule

Default

 

View object instance

$view : \Zend\View\Renderer\RendererInterface

Default

null