issue #0001547 : Plugin Lang and initTranslate is remove from bootstrap
This commit is contained in:
parent
d1eba87bb8
commit
e536a09fd4
@ -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
|
||||
|
47
library/Application/Controller/Plugin/Lang.php
Normal file
47
library/Application/Controller/Plugin/Lang.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user