当前位置: 首页>>代码示例>>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;未经允许,请勿转载。