Translation view helper

category Zend
package Zend_View
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_View_Helper_Abstract

 Methods

Constructor for manually handling

__construct(\Zend_Translate|\Zend_Translate_Adapter $translate = null

Parameters

$translate

\Zend_Translate\Zend_Translate_Adapter

Instance of Zend_Translate

Strategy pattern: currently unutilized

direct() : void
Inherited
inherited_from \Zend_View_Helper_Interface::direct()

Returns the set locale for translations

getLocale() : string | \Zend_Locale

Exceptions

\Zend_View_Exception When no Zend_Translate instance was set

Returns

string\Zend_Locale

Retrieve translation object

getTranslator() : \Zend_Translate_Adapter | null

Returns

\Zend_Translate_Adapternull

Set's an new locale for all further translations

setLocale(string|\Zend_Locale $locale = null) : \Zend_View_Helper_Translate

Parameters

$locale

string\Zend_Locale

New locale to set

Exceptions

\Zend_View_Exception When no Zend_Translate instance was set

Returns

\Zend_View_Helper_Translate

Sets a translation Adapter for translation

setTranslator(\Zend_Translate|\Zend_Translate_Adapter $translate) : \Zend_View_Helper_Translate

Parameters

$translate

\Zend_Translate\Zend_Translate_Adapter

Instance of Zend_Translate

Exceptions

\Zend_View_Exception When no or a false instance was set

Returns

\Zend_View_Helper_Translate

Set the View object

setView(\Zend_View_Interface $view) : \Zend_View_Helper_Abstract
Inherited
inherited_from \Zend_View_Helper_Interface::setView()

Parameters

$view

\Zend_View_Interface

Returns

\Zend_View_Helper_Abstract

Translate a message You can give multiple params or an array of params.

translate(string $messageid = null) : string | \Zend_View_Helper_Translate

If you want to output another locale just set it as last single parameter Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale); Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale);

Parameters

$messageid

string

Id of the message to be translated

Returns

string\Zend_View_Helper_TranslateTranslated message

 Properties

 

View object

$view : \Zend_View_Interface

Default

null
 

Translation object

$_translator : \Zend_Translate_Adapter

Default