Location: PHPKode > scripts > GSD_Controller_Plugin_Language > gsd_controller_plugin_language/GSD/Controller/Plugin/Language.php
<?php
/**
 * Front Controller Plugin
 *
 * @uses	   Zend_Controller_Plugin_Abstract
 * @category   GSD
 * @package	GSD_Controller
 * @subpackage Plugins
 */
class GSD_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract
{
	public function routeShutdown(Zend_Controller_Request_Abstract $request)
	{
		$locale = new Zend_Locale();
		$options = array('scan' => Zend_Translate::LOCALE_FILENAME);
		$translate = new Zend_Translate('gettext', Zend_Registry::get('siteRootDir') . '/application/languages/', 'auto', $options);
		$requestParams = $this->getRequest()->getParams();
		$language = (isset($requestParams['language'])) ? $requestParams['language'] : false;
				if ($language == false) {
					 $language = ($translate->isAvailable($locale->getLanguage())) ? $locale->getLanguage() : 'en';
				}
		if (!$translate->isAvailable($language)) {
			throw new Zend_Controller_Action_Exception('This page dont exist',404);
		} else {
	   $locale->setLocale($language);
			$translate->setLocale($locale);
			Zend_Form::setDefaultTranslator($translate);
			setcookie('lang', $locale->getLanguage(), null, '/');
			Zend_Registry::set('Zend_Locale', $locale);
			Zend_Registry::set('Zend_Translate', $translate);
		}
	}
}


Return current item: GSD_Controller_Plugin_Language