]> dev.renevier.net Git - syj.git/blob - application/controllers/plugins/SyjLocale.php
version 0.1
[syj.git] / application / controllers / plugins / SyjLocale.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 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         if (is_null($lang)) {
11             return;
12         }
13
14         if (!Zend_Registry::isRegistered('Zend_Translate')) {
15             return;
16         }
17
18         $translator = Zend_Registry::get('Zend_Translate');
19         $adapter = $translator->getAdapter();
20         if (!$adapter->isAvailable($lang)) {
21             return;
22         }
23
24         $adapter->setLocale($lang);
25     }
26
27 }