View Helpers
In This Article
Introduction
zend-i18n ships with a set of zend-view helper classes related to internationalization.
These helpers are based on Zend Frameworks's component for the view layer: zend-view and their helpers.
Installation requirements
The view-helper support of zend-i18n depends on the zend-view component, so be sure to have it installed before getting started:
bash $ composer require zendframework/zend-view
@todo Abstract Translator Helper
The AbstractTranslatorHelper view helper is used as a base abstract class for
any helpers that need to translate content. It provides an implementation for
the Zend\I18n\Translator\TranslatorAwareInterface, allowing translator
injection as well as text domain injection.
Public Methods
setTranslator()
setTranslator(
Translator $translator [ ,
string $textDomain = null
] ) : void
Sets the Zend\I18n\Translator\Translator instance to use in the helper. The
$textDomain argument is optional, and provided as a convenienct to allow
setting both the translator and text domain simultaneously.
getTranslator()
getTranslator() : Translator
Returns the Zend\I18n\Translator\Translator instance used by the helper.
hasTranslator()
hasTranslator() : bool
Returns true if the helper composes a Zend\I18n\Translator\Translator instance.
setTranslatorEnabled()
setTranslatorEnabled(bool $enabled) : void
Sets whether or not translations are enabled.
isTranslatorEnabled()
isTranslatorEnabled() : bool
Returns true if translations are enabled.
setTranslatorTextDomain()
setTranslatorTextDomain(string $textDomain) : void
Sets the default translation text domain to use with the helper.
getTranslatorTextDomain()
getTranslatorTextDomain() : string
Returns the current text domain used by the helper.
Found a mistake or want to contribute to the documentation? Edit this page on GitHub!