issue #0001547 : Plugin Lang and initTranslate is remove from bootstrap

This commit is contained in:
Michael RICOIS 2013-05-29 08:50:18 +00:00
parent d1eba87bb8
commit e536a09fd4
2 changed files with 47 additions and 45 deletions

View File

@ -42,51 +42,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
return $router;
}
protected function _initTranslate()
{
$registry = Zend_Registry::getInstance();
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
$identity = $auth->getIdentity();
$lang = $identity->langtmp;
switch($lang) {
case 'en':
$locale = new Zend_Locale('en');
break;
case 'fr':
default:
$locale = new Zend_Locale('fr');
break;
}
} else {
$locale = new Zend_Locale('fr');
}
$translate = new Zend_Translate(
array(
'adapter' => 'gettext',
'content' => APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'fr.mo',
'locale' => 'fr',
'scan' => Zend_Translate::LOCALE_DIRECTORY
)
);
$translate->addTranslation(
array(
'content' => APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'en.mo',
'locale' => 'en',
'scan' => Zend_Translate::LOCALE_DIRECTORY
)
);
$translate->setLocale($locale);
$registry->set('Zend_Locale', $locale);
$registry->set('Zend_Translate', $translate);
return $registry;
}
protected function _initLogging()
{
//Firebug

View File

@ -0,0 +1,47 @@
<?php
class Application_Controller_Plugin_Lang extends Zend_Controller_Plugin_Abstract
{
/**
* Vérifie les autorisations
* Utilise _request et _response hérités et injectés par le FC
*
* @param Zend_Controller_Request_Abstract $request : non utilisé, mais demandé par l'héritage
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
$identity = $auth->getIdentity();
$lang = $identity->langtmp;
switch($lang) {
case 'en':
$locale = new Zend_Locale('en');
break;
case 'fr':
default:
$locale = new Zend_Locale('fr');
break;
}
} else {
$locale = new Zend_Locale('fr');
}
$translate = new Zend_Translate(
array(
'adapter' => 'gettext',
'content' => APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'fr.mo',
'locale' => 'fr',
'scan' => Zend_Translate::LOCALE_DIRECTORY
)
);
$translate->addTranslation(
array(
'content' => APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'en.mo',
'locale' => 'en',
'scan' => Zend_Translate::LOCALE_DIRECTORY
)
);
$translate->setLocale($locale);
}
}