Listing 14.16: Translating within action controllers
public function aboutAction()
{
$this->view->title = $this->_translate->_('About'); A
}
A Translate the title string
Licensed to Menshu You
Zend Framework in Action (Ch01) Manning Publications Co. 46
The final area we need to look at it creation of links from one page to another. Fortunately,
Zend_Framework provides a url builder for us in the shape of the url() view helper. This is shown in listing
14.17.
Listing 14.17: Creating urls using the url() view helper
Add review
A Set the language parameter
B Set the other parameters forouting
As can be seen in listing 14.16, creating a url is simplified using the url() view helper. It can be further
simplified by not passing true as the last parameter ($reset) in which case the helper will ???remember??? the
state of any parameters you do not override. As the lang parameter would never be overridden, it only has to be
specified if the $reset parameter is set to true.
We have now provided comprehensive support for all aspects of translation using Zend_Translate and
adding additional languages can be done very easily by adding the language to the config.
Pages:
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363