]> dev.renevier.net Git - syj.git/blob - application/controllers/plugins/SyjLocale.php
update copyright headers
[syj.git] / application / controllers / plugins / SyjLocale.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_Controllers_Plugins_SyjLocale extends Zend_Controller_Plugin_Abstract
6 {
7
8     public function preDispatch(Zend_Controller_Request_Abstract $request) {
9         $lang = $request->getQuery('lang');
10
11         if ($lang) {
12             setcookie("syj_lang", $lang, 0, "", "", false, true);
13         } else {
14             $lang = $request->getCookie('syj_lang');
15         }
16
17         if (!$lang) {
18             return;
19         }
20
21         $translator = Zend_Registry::get('Zend_Translate');
22         $adapter = $translator->getAdapter();
23         if (!$adapter->isAvailable($lang)) {
24             return;
25         }
26
27         $adapter->setLocale($lang);
28     }
29
30 }