tak wygląda bootstrap.php
function _initSetTranslations() { $translate = new Zend_Translate('gettext', APPLICATION_PATH.'/languages', null, ); $session = new Zend_Session_Namespace('Projekt_'); $local = new Zend_Locale(); $requestedLanguage = $session->language; } else { $local->setLocale(Zend_locale::BROWSER); } $language = $requestedLanguage; } else { $language = 'en'; } Zend_Registry::set('Zend_Translate', $translate); $view->translate = $translate; }
Tak kontroller:
<?php class LanguageswitchController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); } public function indexAction() { // action body } public function switchAction() { // action body $session = new Zend_Session_Namespace('Projekt_'); $session->language = $this->_getParam('lang'); $this->_redirect('library/books/list'); } }
A tak daję linki w layout:
Kod
<a href="<?php $this->url(array('controller' => 'languageswitch',
'action' => 'switch',
'lang' => 'en'));?>">English</a>
<a href="<?php $this->url(array('controller' => 'languageswitch',
'action' => 'switch',
'lang' => 'pl'));?>">Polish</a>
<a href="<?php $this->url(array('controller' => 'languageswitch',
'action' => 'switch',
'lang' => 'jp'));?>">Japanish</a>
'action' => 'switch',
'lang' => 'en'));?>">English</a>
<a href="<?php $this->url(array('controller' => 'languageswitch',
'action' => 'switch',
'lang' => 'pl'));?>">Polish</a>
<a href="<?php $this->url(array('controller' => 'languageswitch',
'action' => 'switch',
'lang' => 'jp'));?>">Japanish</a>
Przy czym po najechaniu kursorem na poszczególny link widzi inny kontroler, zamiast "/languageswitch/switch" wskazuje inny.
Co jest nie tak?