mam aplikację dużo widoków, dużo kontrolerów aby np: odwołać się do języka robione jest to w ten sposób:
$locale = Zend_Registry::get('locale'); $listyCH = $listyModel->getList($locale->getLanguage(), 'chlopiec'); $listyDZ = $listyModel->getList($locale->getLanguage(), 'dziewczynka');
Teraz mam problem ponieważ $locale->getLanguage() zawsze wyświetla 'pl' mimo że strona jest w języku angielskim. Tak wygląda kod Translate:
public function translate () { if ($this->_translate == null) { $this->_translate = new Zend_Translate ('gettext', ROOT_PATH.'/application/default/views/languages', null, array ('scan' => Zend_Translate::LOCALE_FILENAME)); $fc = Zend_Controller_Front::getInstance (); $module = $fc->getDefaultModule (); $locale = Zend_Registry::get ('locale'); $language = $locale->getLanguage (); $session = new Zend_Session_Namespace ('Listy'); // $locale = new Zend_Locale (); $this->_translate->setLocale ($session->language); } else { switch ($_SERVER['SERVER_NAME']) { default: $this->_translate->setLocale ('en'); break; case 'xxx.pl': case 'xxx.localhost': case 'www.xxx.pl': $this->_translate->setLocale ('pl'); break; } } ); } return $this->_translate; }
Jak zrobić to w prosty sposób tak aby obiekt
$locale->getLanguage()
Wyświetlał odpowiednio dla wersji angielskiej 'EN' i dla polskiej 'PL'?