當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Locale::_default方法代碼示例

本文整理匯總了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();
 }
開發者ID:bizanto,項目名稱:Hooked,代碼行數:39,代碼來源:Locale.php

示例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!");
 }
開發者ID:virginiarcruz,項目名稱:xerteonlinetoolkits,代碼行數:27,代碼來源:Locale.php


注:本文中的Zend_Locale::_default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。