当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale::_environment方法代码示例

本文整理汇总了PHP中Zend_Locale::_environment方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::_environment方法的具体用法?PHP Zend_Locale::_environment怎么用?PHP Zend_Locale::_environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Locale的用法示例。


在下文中一共展示了Zend_Locale::_environment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isLocale

 /**
  * Checks if a locale identifier is a real locale or not
  * Examples:
  * "en_XX" refers to "en", which returns true
  * "XX_yy" refers to "root", which returns false
  *
  * @param  string|Zend_Locale  $locale  Locale to check for
  * @param  boolean             $create  If true, create a default locale, if $locale is empty
  * @return false|string   false if given locale is not a locale, else the locale identifier is returned
  */
 public static function isLocale($locale, $create = false)
 {
     if (empty($locale) and $create === true) {
         $locale = new self();
     }
     if ($locale instanceof Zend_Locale) {
         return $locale->toString();
     }
     if (!is_string($locale)) {
         return false;
     }
     if (empty(self::$_auto)) {
         $temp = new self($locale);
         self::$_auto = $temp->getDefault(null, false);
         self::$_browser = $temp->getDefault(self::BROWSER, false);
         self::$_environment = $temp->getDefault(self::ENVIRONMENT, false);
     }
     if ($locale == 'auto') {
         $locale = self::$_auto;
     }
     if ($locale == 'browser') {
         $locale = self::$_browser;
     }
     if ($locale == 'environment') {
         $locale = self::$_environment;
     }
     if (is_array($locale)) {
         $locale = key($locale);
     }
     if (array_key_exists($locale, self::$_localeData)) {
         return $locale;
     } else {
         $locale = explode('_', $locale);
         if (array_key_exists($locale[0], self::$_localeData)) {
             return $locale[0];
         }
     }
     return false;
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:49,代码来源:Locale.php

示例2: _prepareLocale

 /**
  * Internal function, returns a single locale on detection
  *
  * @param  string|Zend_Locale $locale (Optional) Locale to work on
  * @param  boolean            $strict (Optional) Strict preparation
  * @throws Zend_Locale_Exception When no locale is set which is only possible when the class was wrong extended
  * @return string
  */
 private static function _prepareLocale($locale, $strict = false)
 {
     if ($locale instanceof Zend_Locale) {
         $locale = $locale->toString();
     }
     if (is_array($locale)) {
         return '';
     }
     if (empty(self::$_auto) === true) {
         self::$_browser = self::getBrowser();
         self::$_environment = self::getEnvironment();
         self::$_breakChain = true;
         self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
     }
     if (!$strict) {
         if ($locale === 'browser') {
             $locale = self::$_browser;
         }
         if ($locale === 'environment') {
             $locale = self::$_environment;
         }
         if ($locale === 'default') {
             $locale = self::$_default;
         }
         if ($locale === 'auto' or $locale === null) {
             $locale = self::$_auto;
         }
         if (is_array($locale) === true) {
             $locale = key($locale);
         }
     }
     // This can only happen when someone extends Zend_Locale and erases the default
     if ($locale === null) {
         require_once 'Zend/Locale/Exception.php';
         throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
     }
     if (strpos($locale, '-') !== false) {
         $locale = strtr($locale, '-', '_');
     }
     $parts = explode('_', $locale);
     if (!isset(self::$_localeData[$parts[0]])) {
         if (count($parts) == 1 && array_key_exists($parts[0], self::$_territoryData)) {
             return self::$_territoryData[$parts[0]];
         }
         return '';
     }
     foreach ($parts as $key => $value) {
         if (strlen($value) < 2 || strlen($value) > 3) {
             unset($parts[$key]);
         }
     }
     $locale = implode('_', $parts);
     return (string) $locale;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:62,代码来源:Locale.php

示例3: _prepareLocale

 /**
  * Internal function, returns a single locale on detection
  *
  * @param  string|Zend_Locale $locale (Optional) Locale to work on
  * @param  boolean            $strict (Optional) Strict preparation
  * @throws Zend_Locale_Exception When no locale is set which is only possible when the class was wrong extended
  * @return string
  */
 private static function _prepareLocale($locale, $strict = false)
 {
     if (is_array($locale)) {
         return '';
     }
     if (empty(self::$_auto) === true) {
         self::$_browser = self::getBrowser();
         self::$_environment = self::getEnvironment();
         self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
     }
     if (!$strict) {
         if ($locale === 'browser') {
             $locale = self::$_browser;
         }
         if ($locale === 'environment') {
             $locale = self::$_environment;
         }
         if ($locale === 'default') {
             $locale = self::$_default;
         }
         if ($locale === 'auto' or empty($locale)) {
             $locale = self::$_auto;
         }
         if (is_array($locale) === true) {
             $locale = key($locale);
         }
     }
     // This can only happen when someone extends Zend_Locale and erases the default
     if (empty($locale)) {
         require_once 'Zend/Locale/Exception.php';
         throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
     }
     if (strpos($locale, '-') !== false) {
         $locale = strtr($locale, '-', '_');
     }
     return (string) $locale;
 }
开发者ID:uester,项目名称:escolaonline,代码行数:45,代码来源:Locale.php


注:本文中的Zend_Locale::_environment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。