本文整理汇总了PHP中Zend_Locale::_default方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::_default方法的具体用法?PHP Zend_Locale::_default怎么用?PHP Zend_Locale::_default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Locale
的用法示例。
在下文中一共展示了Zend_Locale::_default方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefault
/**
* Sets a new default locale which will be used when no locale can be detected
* If provided you can set a quality between 0 and 1 (or 2 and 100)
* which represents the percent of quality the browser
* requested within HTTP
*
* @param string|Zend_Locale $locale Locale to set
* @param float $quality The quality to set from 0 to 1
* @throws Zend_Locale_Exception When a autolocale was given
* @throws Zend_Locale_Exception When a unknown locale was given
* @return void
*/
public static function setDefault($locale, $quality = 1)
{
if ($locale === 'auto' or $locale === 'root' or $locale === 'default' or $locale === 'environment' or $locale === 'browser') {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
}
if ($quality < 0.1 or $quality > 100) {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Quality must be between 0.1 and 100");
}
if ($quality > 1) {
$quality /= 100;
}
$locale = self::_prepareLocale($locale);
if (isset(self::$_localeData[(string) $locale]) === true) {
self::$_default = array((string) $locale => $quality);
} else {
$elocale = explode('_', (string) $locale);
if (isset(self::$_localeData[$elocale[0]]) === true) {
self::$_default = array($elocale[0] => $quality);
} else {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Unknown locale '" . (string) $locale . "' can not be set as default!");
}
}
self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
}
示例2: setDefault
/**
* Sets a new default locale
*
* @param string|Zend_Locale $locale Locale to set
* @throws Zend_Locale_Exception When a autolocale was given
* @throws Zend_Locale_Exception When a unknown locale was given
* @return boolean
*/
public static function setDefault($locale)
{
if ($locale === 'auto' or $locale === 'root' or $locale === 'environment' or $locale === 'browser') {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
}
if (isset(self::$_localeData[$locale]) === true) {
self::$_default = $locale;
return true;
} else {
$locale = explode('_', $locale);
if (isset(self::$_localeData[$locale[0]]) === true) {
self::$_default = $locale[0];
return true;
}
}
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Unknown locale '{$locale}' can not be set as default!");
}