简体   繁体   中英

'No entry is registered for key 'Zend_Translate'

So I have to change a website which was written on Zend framework. I downloaded the source files and want to run the website locally. But I keep getting this error 'No entry is registered for key 'Zend_Translate'. I have no experience with the Zend framework, so I dont really know what is the problem now. Can anyone help?

Your application requires Translator and it needs to be linked in Registry. Basically you need to add Transaltor (if it's not added already):

//Bootstrap.php
$locale = new Zend_Locale('en_GB'); //current locale
Zend_Registry::set('Zend_Locale', $locale); //this is optional but better to add this
$translate = new Zend_Translate(array('adapter' => 'tmx',
    'content' => APPLICATION_PATH . '/configs/translations.tmx',
    'locale' => $locale));
Zend_Registry::set('Zend_Translate', $translator); //here you add translator to registry

In this case translation file is translations.tmx which has syntax like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tmx SYSTEM "tmx14.dtd">
<tmx version="1.4">
   <body>
       <tu tuid='ADD_BASKET'>
            <tuv xml:lang="pl_PL"><seg>Dodaj do koszyka</seg></tuv>
            <tuv xml:lang="en_GB">Add to basket<seg></seg></tuv>
       </tu>
       <tu tuid='RECRIUT'>
            <tuv xml:lang="pl_PL"><seg>rekrutacja</seg></tuv>
            <tuv xml:lang="en_GB"><seg>recruit</seg></tuv>
       </tu>
   </body>
</tmx>

Zend supports interfaces to few other translation file formats if you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM