diff --git a/newscoop/library/Newscoop/SmartyView.php b/newscoop/library/Newscoop/SmartyView.php index 2fcea8e8db..6621f63758 100644 --- a/newscoop/library/Newscoop/SmartyView.php +++ b/newscoop/library/Newscoop/SmartyView.php @@ -30,8 +30,19 @@ public function _run() $this->smarty->assign($key, $val); } + $context = $this->smarty->context(); + $locale = \Zend_Controller_Front::getInstance()->getParam('locale'); + $em = \Zend_Registry::get('container')->getService('em'); + try { + $language = $em->getRepository('Newscoop\Entity\Language') + ->findOneByCode($locale); + $context->language = new \MetaLanguage($language->getId()); + } catch (\Exception $e) { + // Do nothing, default language will be used + } + $this->smarty->assign('view', $this); - $this->smarty->assign('gimme', $this->smarty->context()); + $this->smarty->assign('gimme', $context); $file = array_shift(func_get_args()); $this->smarty->display($file); diff --git a/newscoop/src/Newscoop/ZendBridgeBundle/Controller/BridgeController.php b/newscoop/src/Newscoop/ZendBridgeBundle/Controller/BridgeController.php index f2293e103d..0f96d900c2 100644 --- a/newscoop/src/Newscoop/ZendBridgeBundle/Controller/BridgeController.php +++ b/newscoop/src/Newscoop/ZendBridgeBundle/Controller/BridgeController.php @@ -55,6 +55,7 @@ public function indexAction(Request $request) } $front->setParam('bootstrap', $bootstrap); + $front->setParam('locale', $request->getLocale()); $front->setBaseUrl('/'); $response = $front->dispatch();