2013-04-23 09:07:06 +00:00
|
|
|
<?php
|
|
|
|
class Application_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract
|
|
|
|
{
|
|
|
|
public function preDispatch(Zend_Controller_Request_Abstract $request)
|
|
|
|
{
|
|
|
|
$registry = Zend_Registry::getInstance();
|
2013-04-30 12:42:56 +00:00
|
|
|
$session = new Zend_Session_Namespace('Zend_Auth');
|
2013-04-23 09:07:06 +00:00
|
|
|
$translate = $registry->get('Zend_Translate');
|
|
|
|
$currLocale = $translate->getLocale();
|
|
|
|
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
|
|
|
|
$lang = $request->getParam('lang', '');
|
|
|
|
|
|
|
|
switch ($lang) {
|
|
|
|
case "fr":
|
|
|
|
$langLocale = 'fr';
|
|
|
|
break;
|
|
|
|
case "en":
|
|
|
|
$langLocale = 'en';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$langLocale = $user->getLang();
|
|
|
|
}
|
|
|
|
|
|
|
|
$newLocale = new Zend_Locale();
|
|
|
|
$newLocale->setLocale($langLocale);
|
|
|
|
$registry->set('Zend_Locale', $newLocale);
|
2013-04-30 12:42:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
$session->lang = $langLocale;
|
|
|
|
|
2013-04-23 09:07:06 +00:00
|
|
|
$translate->setLocale($langLocale);
|
|
|
|
|
|
|
|
$registry->set('Zend_Translate', $translate);
|
|
|
|
}
|
|
|
|
}
|