/** * Returns a list of global variables to add to the existing list. * * @return array An array of global variables. * * @since 1.0 */ public function getGlobals() { /* @type \JTracker\Application $application */ $application = $this->container->get('app'); return array('uri' => $application->get('uri'), 'offset' => $application->getUser()->params->get('timezone') ? $application->getUser()->params->get('timezone') : $application->get('system.offset'), 'languages' => $application->get('languages'), 'jdebug' => JDEBUG, 'lang' => $application->getUser()->params->get('language') ? $application->getUser()->params->get('language') : g11n::getCurrent(), 'g11nJavaScript' => g11n::getJavaScript(), 'useCDN' => $application->get('system.use_cdn')); }
/** * Load a foreign language. * * @return $this * * @since 1.0 */ protected function loadLanguage() { // Get the language tag from user input. $lang = $this->input->get('lang'); if ($lang) { if (false == in_array($lang, $this->get('languages'))) { // Unknown language from user input - fall back to default $lang = g11n::getDefault(); } if (false == in_array($lang, $this->get('languages'))) { // Unknown default language - Fall back to British. $lang = 'en-GB'; } } else { $lang = g11n::getCurrent(); if (false == in_array($lang, $this->get('languages'))) { // Unknown current language - Fall back to British. $lang = 'en-GB'; } } if ($lang) { // Set the current language if anything has been found. g11n::setCurrent($lang); } // Set language debugging. g11n::setDebug($this->get('debug.language')); // Set the language cache directory. if ('vagrant' == getenv('JTRACKER_ENVIRONMENT')) { g11n::setCacheDir('/tmp'); } else { g11n::setCacheDir(JPATH_ROOT . '/cache'); } // Load the CLI language file. g11n::addDomainPath('CLI', JPATH_ROOT); g11n::loadLanguage('cli', 'CLI'); return $this; }