2013-04-23 09:07:06 +00:00
|
|
|
<?php
|
2013-05-13 13:58:18 +00:00
|
|
|
class Application_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract
|
2013-04-23 09:07:06 +00:00
|
|
|
{
|
2013-05-24 10:59:19 +00:00
|
|
|
public function postDispatch(Zend_Controller_Request_Abstract $request)
|
2013-04-23 09:07:06 +00:00
|
|
|
{
|
2013-05-24 10:59:19 +00:00
|
|
|
$registry = Zend_Registry::getInstance();
|
|
|
|
$translate = $registry->get('Zend_Translate');
|
|
|
|
$currLocale = $translate->getLocale();
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
if ( $user->isLog() ) {
|
|
|
|
$langtmp = $request->getParam('langtmp', '');
|
|
|
|
if (!$langtmp)
|
|
|
|
$langtmp = $user->getLangTmp() ? $user->getLangTmp() : $user->getLang();
|
|
|
|
$newLocale = new Zend_Locale();
|
|
|
|
$newLocale->setLocale($langtmp);
|
|
|
|
$registry->set('Zend_Locale', $newLocale);
|
|
|
|
$translate->setLocale($langtmp);
|
|
|
|
$user->setLangTmp($langtmp);
|
|
|
|
$registry->set('Zend_Translate', $translate);
|
|
|
|
} else {
|
|
|
|
$langtmp = 'fr';
|
|
|
|
}
|
2013-04-23 09:07:06 +00:00
|
|
|
}
|
|
|
|
}
|