2008年9月17日星期三

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

There were plans for providing a _ helper, but it turned out it is not possible due to technical restrictions.

However, you can approach the problem from the other side - tune your gettext collection tool to harvest translate() functions.
This is possible and easy with POEdit for example.

Regards,
Emil Ivanov

2008/9/17 Thomas Gelf <thomas@gelf.net>
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





--
My place to share my ideas:
http://vladev.blogspot.com

没有评论: