本文整理汇总了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;
}
示例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')));
}
示例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');
}
示例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;
}