Zend\I18n\View\Helper\Plural
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 prefered 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:
- http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
- https://developer.mozilla.org/en-US/docs/Localization_and_Plurals
Synopsis
class Plural
extends AbstractHelper
{
- // members
- protected Rule $rule;
- // Inherited members from AbstractHelper
- protected RendererInterface $view;
- // methods
- public void __construct()
- public string __invoke()
- public Plural setPluralRule()
- public Rule getPluralRule()
- // Inherited methods from AbstractHelper
- public AbstractHelper setView()
- public null|Renderer getView()
Hierarchy
Extends
Members
protected
- $rule
—
Zend\I18n\Translator\Plural\Rule
Plural rule to use - $view
—
Zend\View\Renderer\RendererInterface
View object instance
Methods
public
- __construct()
- __invoke() — 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
- getPluralRule() — Get the plural rule to use
- setPluralRule() — Set the plural rule to use