PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Routing for translations

Not every message ID can be translated. But sometimes is can be useful to output the translation from another language instead of returning the message ID itself. You can archive this by using the route option.

You can add one route for every language. See the following example:

<?php
$translate 
= new Zend_Translate(
    array(
        
'adapter' => $adapter,
        
'content' => $content,
        
'locale'  => $locale,
        
'route'   => array('fr' => 'en''de' => 'fr')
    )
);

The above returns a english translation for all messages which can not be translated to french. And it returns a french translation for all messages which can not be translated to german. It will even return an english translation for all messages which can wether be translated to german nor to french. So you can even define a complete translation chain.

This feature seems ot be interesting for anyone. But be aware that returning translations for wrong or other languages can be problematic when the user does not understand this language. So you should always use this feature sparingly.

Zend Framework