Issue #0001547: interface language via langAction(), not Language plugin

This commit is contained in:
Aram HARUTYUNYAN 2013-05-27 13:35:57 +00:00
parent 7c412abe18
commit 9a1804d744
9 changed files with 46 additions and 10 deletions

View File

@ -44,8 +44,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
protected function _initTranslate()
{
$registry = Zend_Registry::getInstance();
$registry = Zend_Registry::getInstance();
$locale = new Zend_Locale('fr_FR');
$translate = new Zend_Translate(
array(
'adapter' => 'gettext',
@ -62,7 +62,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'scan' => Zend_Translate::LOCALE_DIRECTORY
)
);
$registry->set('Zend_Locale', $locale);
$registry->set('Zend_Translate', $translate);
return $registry;
}

View File

@ -61,6 +61,7 @@ class UserController extends Zend_Controller_Action
public function indexAction()
{
$user = new Scores_Utilisateur();
if (!$user->checkPerm('MONPROFIL')){
$this->_forward('perms', 'error');
}
@ -484,6 +485,31 @@ class UserController extends Zend_Controller_Action
}
}
/**
* Changer la langue de l'utilisateur
*/
public function langAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$user = new Scores_Utilisateur();
$locale = new Zend_Locale();
$url = $this->getRequest()->getParam('last_url', null);
$langtmp = $this->getRequest()->getParam('langtmp', null);
$registry = Zend_Registry::getInstance();
$translate = $registry->get('Zend_Translate');
$locale->setLocale($langtmp);
$registry->set('Zend_Locale', $locale);
$translate->setLocale($langtmp);
$user->setLangTmp($langtmp);
$registry->set('Zend_Translate', $translate);
$this->_redirect($url);
}
/**
* Changer le theme de l'utilisateur

View File

@ -12,7 +12,7 @@ pour en savoir plus cliquez-ici</a></span>
<p>&copy; 2006-<?php echo date('Y')?> Scores &amp; D&eacute;cisions SAS -
Tous droits r&eacute;serv&eacute;s -
<a href="http://www.scores-decisions.com/mentions.php" target="_blank">
Mentions l&eacute;gales</a> -
<a href=<?=$this->url(array('langtmp' => 'fr'));?>><img src="/themes/default/images/drapeaux/fr.png"/></a>
<a href=<?=$this->url(array('langtmp' => 'en'));?>><img src="/themes/default/images/drapeaux/en.png"/></a>
Mentions l&eacute;gales</a> -
<img class='flag' id='fr' src="/themes/default/images/drapeaux/fr.png"/>
<img class='flag' id='en' src="/themes/default/images/drapeaux/en.png"/>
</p>

View File

@ -0,0 +1 @@
<div class="infoData"></div>

View File

@ -1,5 +1,17 @@
$(document).ready(function(){
$('img.flag').on('click', function() {
var cur_url = window.location.pathname;
$.ajax({
type: 'post',
url: '/user/lang',
data: { langtmp: $(this).attr('id'), last_url: cur_url },
success: function(result) {
window.location.pathname = cur_url;
}
});
});
//Auto Scroll
$(window).scroll(function(e) {
e.stopPropagation();

View File

@ -16,7 +16,6 @@ resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu"
resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Pdf"
resources.frontController.plugins.Xml = "Application_Controller_Plugin_Xml"
resources.frontController.plugins.Cgu = "Application_Controller_Plugin_Cgu"
resources.frontController.plugins.Language = "Application_Controller_Plugin_Language"
resources.frontController.params.displayExceptions = 0
resources.layout.layout = "main"
resources.layout.layoutPath = APPLICATION_PATH "/views/default"

View File

@ -16,7 +16,6 @@ resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu"
resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Pdf"
resources.frontController.plugins.Xml = "Application_Controller_Plugin_Xml"
resources.frontController.plugins.Cgu = "Application_Controller_Plugin_Cgu"
resources.frontController.plugins.Language = "Application_Controller_Plugin_Language"
resources.frontController.params.displayExceptions = 0
resources.layout.layout = "main"
resources.layout.layoutPath = APPLICATION_PATH "/views/default"

View File

@ -16,7 +16,6 @@ resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu"
resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Pdf"
resources.frontController.plugins.Xml = "Application_Controller_Plugin_Xml"
resources.frontController.plugins.Cgu = "Application_Controller_Plugin_Cgu"
resources.frontController.plugins.Language = "Application_Controller_Plugin_Language"
resources.frontController.params.displayExceptions = 0
resources.layout.layout = "main"
resources.layout.layoutPath = APPLICATION_PATH "/views/default"

View File

@ -16,7 +16,6 @@ resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu"
resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Pdf"
resources.frontController.plugins.Xml = "Application_Controller_Plugin_Xml"
resources.frontController.plugins.Cgu = "Application_Controller_Plugin_Cgu"
resources.frontController.plugins.Language = "Application_Controller_Plugin_Language"
resources.frontController.params.displayExceptions = 0
resources.layout.layout = "main"
resources.layout.layoutPath = APPLICATION_PATH "/views/default"