/** * Get a language object. * * @return $this Method allows chaining * * @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'; } // Store the language tag. $this->getSession()->set('lang', $lang); $this->getUser()->params->set('language', $lang); } else { // Get the language tag from the user params or session. Default to British. $lang = $this->getUser()->params->get('language', $this->getSession()->get('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 core language file. g11n::addDomainPath('Core', JPATH_ROOT . '/src'); g11n::loadLanguage('JTracker', 'Core'); // Load template language files. g11n::addDomainPath('Template', JPATH_ROOT . '/templates'); g11n::loadLanguage('JTracker', 'Template'); // Add the App domain path. g11n::addDomainPath('App', JPATH_ROOT . '/src/App'); if ($this->get('debug.system') || $this->get('debug.database') || $this->get('debug.language')) { // Load the Debug App language file. g11n::loadLanguage('Debug', 'App'); } return $this; }
/** * 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; }