Fetching translated strings, keeping in the philosophy of Zend framework I have been wondering this for a while. Take this example:

&lt;?= Zend_Registry::get('translate')-&gt;_('translate me!');


I have my views cluttured with such code. My coworkers also complain often that its a lot to type juste to get translation and since it is repeated all over the place it gets tedious.

Some of them would love some global function that wraps everything in a short name like:

function t($text){
    return Zend_Registry::get('translate')-&gt;_($text);
}


But to me this is not good design and kinda defeats the idea of putting my translation object in the registry.

So I was wondering what others do to avoid having to write all this unnecessary code.

One solution would be to do in my controller:

$this-&gt;view-&gt;t = Zend_Registry::get('translate);


and then in my view just:

&lt;?= $this-&gt;t-&gt;_('translate me!'); ?&gt;


Another would be to create a view helper that does the job:

&lt;?= this-&gt;translate('translate me!');?&gt;


But it is more work and again adds a layer of logic on top of the already pretty robust and straigthforward Zend_Registry+ZendTranslate.
The two real questions are:


What are the advantages of having this in Zend_Registry?
What would you loose when using a helper function?


I believe the answers to these questions lead to this: use the helper function. This will:


save you a lot of typing,
highlight more importants parts of the code,
only add a tiny new layer of abstraction which is trivial to understand.


"Good design" is not about factories, registries, or whatever. It's about code that is easy to maintain and improve. The function is not going to make this any harder. If there's a translation error, the fix will stay the same: was the key correct? Is the stored translation correct? Still easy.