class TranslateViewHelper extends AbstractViewHelper (View source)

Returns translated message using source message or key ID.

Also replaces all placeholders with formatted versions of provided values.

= Examples =

Unregistered User ``` translation of label with the id "user.unregistered" and a fallback to "Unregistered User" {f:translate(id: 'some.label.id', value: 'fallback result')} ``` translation of label with the id "some.label.id" and a fallback to "fallback result" ``` translation from custom source "SomeLabelsCatalog" for locale "de_DE" ``` translation from custom source "LabelsCatalog" in "OtherPackage" ``` translation of the label "Untranslated foo and 99.9" Untranslated label ``` translation of the label "Untranslated label"

Properties

protected RenderingContextInterface $renderingContext from  AbstractViewHelper
protected ControllerContext $controllerContext

Controller Context to use

from  AbstractViewHelper
protected ObjectManagerInterface $objectManager from  AbstractViewHelper
protected LoggerInterface $logger from  AbstractViewHelper
protected Translator $translator

Methods

void
setRenderingContext(RenderingContextInterface $renderingContext)

No description

void
injectObjectManager(ObjectManagerInterface $objectManager)

No description

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

void
initializeArguments()

Initialize arguments

string
render()

Renders the translated label.

injectTranslator(Translator $translator)

No description

Details

void setRenderingContext(RenderingContextInterface $renderingContext)

No description

Parameters

RenderingContextInterface $renderingContext

Return Value

void

void injectObjectManager(ObjectManagerInterface $objectManager)

No description

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

bool isEscapingInterceptorEnabled()

No description

Return Value

bool

void initializeArguments()

Initialize arguments

Return Value

void

string render()

Renders the translated label.

Replaces all placeholders with corresponding values if they exist in the translated label.

Return Value

string

Translated label or source label / ID key

Exceptions

Exception

injectTranslator(Translator $translator)

No description

Parameters

Translator $translator