Search code examples
zend-frameworkhyperlinkzend-translate

how to assign url to words which make part from text translated with Zend_Translate?


I am using Zend Framework and Zend_Translate, Array adapter. Let's say I have the following article: "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur" and translations of it in the languages I will use on my web site. The words quisquam, dolorem, consectetur represent links. I would like to echo the whole article in my view script, with the code: echo $this->translate->_('someArticle');. But obviously mentioned words won't be displayed as links. Is it possible to somehow scan a view script for those words that represent links, to be displayed as such using url declared for example in the respective controller? Or do I have to translate by pieces before and after words that are links? Thank You.


Solution

  • The only solution I've found so far is to insert links inside translations. Example: In the view script: echo $this->translate->_('someArticle'); in translation file (array adapter): "someArticle" => "Neque porro quisquam est qui <a href=\"/ControllerName/methodName\">dolorem</a> ipsum quia dolor sit amet, consectetur" That's it: dolorem will be displayd as link. Just do not forget to escape "" with back slash.