View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_View_Helper_Translate
{zone-data}

{zone-data:proposer-list}
[thomas|~thomas]
{zone-data}

{zone-data:revision}
2.0 - 13 January 2008: Finished implementation
1.1 - 3 November 2007: Small adoptions
1.0 - 1 November 2007: Initial revision
{zone-data}

{zone-data:overview}
Zend_View_Helper_Translate is an view helper for having easy and simple integration of Zend_Translate within the view.
{zone-data}

{zone-data:references}
* [Zend_Translate]
{zone-data}

{zone-data:requirements}
Requires a Zend_Translate instance to operate. It will add the possibility for users to translate messages from within the view without much coding.
{zone-data}

{zone-data:dependencies}
* Zend_Translate
{zone-data}

{zone-data:operation}
Translates messages through Zend_Translate. Can accept parameters to be integrated.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] [Proposal finished|http://framework.zend.com/wiki/display/ZFPROP/Zend_View_Helper_Translate+-+Thomas+Weidner]
* Milestone 2: \[DONE\] Class integration
* Milestone 3: \[DONE\] Unit tests
* Milestone 4: \[DONE\] Documentation
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_Translate
{zone-data}

{zone-data:use-cases}
||UC-01||
// simple translation from within the view
$this->translate('Translate this');

||UC-02||
// translation with one parameter from within the view
$this->translate('Translate this %1\$s', 'again');

||UC-03||
// translation with multiple parameters from within the view
$this->translate('Translate this %1\$s with %2\$s and %3\$s %4\%s', 'again', 'one', 'another', 10);

||UC-04||
// translation with multiple parameters from within the view
$this->translate('Translate this %1\$s with %2\$s and %3\$s %4\%s', array('again', 'one', 'another', 10));
{zone-data}

{zone-data:skeletons}
{code}
// throws Zend_Translate_Exception !!!
class Zend_View_Helper_Translate {

private $_translation; // Zend_Translate_Adapter

/**
* Constructor for Zend_View_Helper_Translate
*
* @param $translation Zend_Translate_Adapter for translation
*/
public function __construct(Zend_Translate_Adapter $translation);

/**
* Translates the given messageid
* Accepts multiple additional parameters, see use cases
*
* @param string $messageid The messageid to translate
* @throws Zend_Translate_Exception
* @returns string Translation
*/
public function translate($messageid);
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>