sometimes a message can not be translated. In this case the original message id will be returned.
But it could be useful to return the translation for another language instead of the message id.
This is called “translation routing” and supported with the next minor release.
Let’s see an example:
$translate = new Zend_Translate(array( 'adapter' => Zend_Translate::AN_ARRAY, 'content' => $mytranslations, 'route' => array('de' => 'en') ));
Now we have a message id of “HEAD”… a user requesting german would expect to get “Meine Überschrift”.
But when there is no translation for this message id he would see “HEAD”.
With the set routing Zend_Translate will internally change the language to the new route and try to translate the message id with the other language.
So he would get “My Header” instead “HEAD”.
This feature seems to solve all problems for those who have no complete translations. But there are also some negs which should be thought of:
1.) You can not route a language to two others.
2.) When Zend_Translate is routing you will still get an “untranslated notice” for every message id and language which can not be translated
3.) When you route users to a language which they don’t understand you are irritating them
You can also build a translation chain by routing from several languages in a sort of priority:
Let’s see an example:
$translate = new Zend_Translate(array( 'adapter' => Zend_Translate::AN_ARRAY, 'content' => $mytranslations, 'route' => array('de' => 'en', 'en' => 'fr') ));
This creates the following chain:
GERMAN => ENGLISH => FRENCH
So german could return english when there is no translation. And when there is no translation for english it would even return french.
Now you could say: Let’s break translation and add a circle routing, something like this:
$translate = new Zend_Translate(array( 'adapter' => Zend_Translate::AN_ARRAY, 'content' => $mytranslations, 'route' => array('de' => 'en', 'en' => 'de') ));
GERMAN => ENGLISH => GERMAN
What now happens is that german returns english, and english returns german when there is no translation. But when there is no english translation it does not try to return german again, instead it returns the message id itself.
So you will always have a translation.
Further informations can be retrieved within the official mailing lists and within IRC.
I hope you find this feature useful. More to come soon…
I18N Team Leader, Zend Framework
Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework