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


PHP Zend_Locale::getQuestion方法代码示例

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


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

示例1: setLocale

 /**
  * Sets the locale.
  *
  * @param Zend_Locale|string|null
  * @return Jrm_Filter_Boolean
  */
 public function setLocale($locale)
 {
     $this->_localeValues = array();
     if (!is_null($locale)) {
         if (!class_exists('Zend_Locale')) {
             require_once 'Zend/Locale.php';
         }
         if (!$locale instanceof Zend_Locale) {
             $locale = new Zend_Locale($locale);
         }
         $q = $locale->getQuestion();
         $this->_localeValues = array($q['yes'] => true, $q['yesabbr'] => true, $q['no'] => false, $q['noabbr'] => false);
     }
     return $this;
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:21,代码来源:Boolean.php

示例2: testgetQuestion

 /**
  * test getQuestion
  * expected true
  */
 public function testgetQuestion()
 {
     $value = new Zend_Locale();
     $list = $value->getQuestion();
     $this->assertTrue(isset($list['yes']));
     $list = $value->getQuestion('de');
     $this->assertEquals('ja', $list['yes']);
     $this->assertTrue(is_array($value->getQuestion('auto')));
     $this->assertTrue(is_array($value->getQuestion('browser')));
     $this->assertTrue(is_array($value->getQuestion('environment')));
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:15,代码来源:LocaleTest.php

示例3: testgetQuestion

 /**
  * test getQuestion
  * expected true
  */
 public function testgetQuestion()
 {
     $value = new Zend_Locale();
     $list = $value->getQuestion();
     $this->assertTrue(isset($list['yes']), 'Question not returned');
     $list = $value->getQuestion('de');
     $this->assertTrue(isset($list['yes']), 'Question not returned');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:LocaleTest.php

示例4: _format

 /**
  * Reads a normalized value, localizes and returns it.
  * Returns an empty string if no value is passed.
  * @param mixed $value
  * @param string $type (boolean|date|time|integer|float|decimal|filesize)
  * @param integer $num_of_decimals used only if type is float or decimal
  * @return mixed
  */
 private function _format($value, $type, $num_of_decimals)
 {
     if (strlen($value) == 0) {
         return '';
     }
     switch ($type) {
         case 'boolean':
             $value = $value == 1 ? 'yes' : 'no';
             $yes_no = Zend_Locale::getQuestion($this->_locale_engine);
             return $yes_no[$value];
         case 'date':
             $date = new Zend_Date($value, "yyyy-MM-dd", $this->_locale_engine);
             return $date->get(Zend_Date::DATES, $this->_locale_engine);
         case 'time':
             $date = new Zend_Date($value, "HH:mm:ss", $this->_locale_engine);
             return $date->get(Zend_Date::TIME_SHORT, $this->_locale_engine);
         case 'datetime':
             $date = new Zend_Date($value, "yyyy-MM-dd HH:mm:ss", $this->_locale_engine);
             return $date->get(Zend_Date::DATES, $this->_locale_engine) . ' ' . $date->get(Zend_Date::TIME_MEDIUM, $this->_locale_engine);
         case 'integer':
             return Zend_Locale_Format::toNumber($value, array('precision' => 0, 'locale' => $this->_locale_engine));
         case 'float':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 3;
             }
             return Zend_Locale_Format::toNumber($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine));
         case 'decimal':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 2;
             }
             return Zend_Locale_Format::toNumber($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine));
         case 'filesize':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 2;
             }
             $units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
             for ($i = 0; $value > 1024 and $i < count($units) - 1; $i++) {
                 $value /= 1024;
             }
             return Zend_Locale_Format::toNumber($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine)) . " {$units[$i]}";
     }
     return $value;
 }
开发者ID:eliudiaz,项目名称:p4a,代码行数:51,代码来源:p4a_i18n.php


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