本文整理匯總了PHP中Locale::setCurrentLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Locale::setCurrentLocale方法的具體用法?PHP Locale::setCurrentLocale怎麽用?PHP Locale::setCurrentLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Locale
的用法示例。
在下文中一共展示了Locale::setCurrentLocale方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCreate
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);
}
示例2: loadLocale
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;
}
示例3: Exception
* @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:
*/