Pipe a Zend View into the Google Translate service?

144 Views Asked by At

I have seen all of the examples of using google translate with the zend framework, and I have the ability to translate strings of text with no problem.

What I'm proposing is to build a "view helper?" that would take the rendered view and send the content over to google before rendering to the screen.

Ideally, it would cache the contents to reduce the overhead. The API charges at the character level, so let's save a bit of cash, right?

I'm still a ZF noob, so I just need some pointers on how to intercept the view before rendering.

ps. <3 Stackoverflow!!!

2

There are 2 best solutions below

0
mpm On

Check the view renderer helper, you might want to extend it for your needs :

http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.viewrenderer

you might want to check the layout helper too in the action helpers , and extend it to translate the layout :

http://framework.zend.com/manual/en/zend.layout.quickstart.html

0
Tomáš Fejfar On

Simpliest would be:

$renderedView = $this->view->render('some-view');

Or you can create dispatchLoopShutdown plugin:

$renderedLayout = $request->getBody()

Or postDispatch()... and take the cview from response segment :)