function testCreate() { // attempt to create non-existing locale $locale = Locale::getInstance('enz'); //$this->assertFalse($locale); // create existing locale $locale = Locale::getInstance('en'); $this->assertTrue($locale instanceof Locale); // set as current locale Locale::setCurrentLocale('en'); $current = Locale::getCurrentLocale(); $this->assertSame($current, $locale); }
private function loadLocale() { if (empty($this->locale)) { ClassLoader::import('library.locale.Locale'); $this->locale = Locale::getInstance($this->localeName); $this->locale->translationManager()->setCacheFileDir(ClassLoader::getRealPath('storage.language')); foreach ($this->getConfigContainer()->getLanguageDirectories() as $dir) { $this->locale->translationManager()->setDefinitionFileDir($dir); } $this->locale->translationManager()->setDefinitionFileDir(ClassLoader::getRealPath('storage.language')); Locale::setCurrentLocale($this->localeName); $this->loadLanguageFiles(); } return $this->locale; }
* @version Subversion $Id$ * @link http://www.wifidog.org/ */ /** * Load required files */ require_once 'classes/Locale.php'; if (!empty($_REQUEST['wifidog_language'])) { $session = Session::getObject(); //echo "Setting to $_REQUEST[wifidog_language]<br/>"; $AVAIL_LOCALE_ARRAY = LocaleList::getAvailableLanguageArray(); /* Try to guess the lang */ if (!empty($AVAIL_LOCALE_ARRAY[$_REQUEST['wifidog_language']])) { $session->set(SESS_LANGUAGE_VAR, $_REQUEST['wifidog_language']); } else { throw new Exception(htmlspecialchars($_REQUEST['wifidog_language']) . " is not a valid locale"); } } $locale = Locale::getCurrentLocale(); Locale::setCurrentLocale($locale); $locale_id = $locale->getId(); if (isset($smarty)) { $smarty->assign("lang_id", $locale_id); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */