2008年9月17日星期三

[fw-mvc] Correct way to create a _()-ViewHelper for translations

As most scripts creating .pot files by parsing PHP source code expect
a _() function, I really would like to keep them ;-) So as the easiest
solution I figured out the following one:

> // Filename: My/View/Helper/.php
>
> class My_View_Helper__ extends Zend_View_Helper_Translate
> {
> public function _($messageid = null)
> {
> return $this->translate($messageid);
> }
> }

As of the unusual file- and class-name it looks like an awful hack,
so my question is: is this the right way to do what I'm wanting to
achieve? And if so: would it make sense for ZF to provide a
_()-ViewHelper per default?

Kind regards,
Thomas Gelf

没有评论: