本文整理汇总了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:
*/