本文整理汇总了PHP中Zend\Locale\Locale::getTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getTranslation方法的具体用法?PHP Locale::getTranslation怎么用?PHP Locale::getTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Locale\Locale
的用法示例。
在下文中一共展示了Locale::getTranslation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLocale
/**
* Sets the locale to use
*
* @param string|\Zend\Locale\Locale $locale
* @throws \Zend\Validator\Exception On unrecognised region
* @throws \Zend\Validator\Exception On not detected format
* @return \Zend\Validator\PostCode Provides fluid interface
*/
public function setLocale($locale = null)
{
$this->_locale = Locale\Locale::findLocale($locale);
$locale = new Locale\Locale($this->_locale);
$region = $locale->getRegion();
if (empty($region)) {
throw new Exception\InvalidArgumentException("Unable to detect a region for the locale '$locale'");
}
$format = Locale\Locale::getTranslation(
$locale->getRegion(),
'postaltoterritory',
$this->_locale
);
if (empty($format)) {
throw new Exception\InvalidArgumentException("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
}
$this->setFormat($format);
return $this;
}
示例2: _getLocalizedQuestion
/**
* Determine the value of a localized string, and compare it to a given value
*
* @param string $value
* @param boolean $yes
* @param array $locale
* @return boolean
*/
protected function _getLocalizedQuestion($value, $yes, $locale)
{
if ($yes == true) {
$question = 'yes';
$return = true;
} else {
$question = 'no';
$return = false;
}
$str = Locale::getTranslation($question, 'question', $locale);
$str = explode(':', $str);
if (!empty($str)) {
foreach ($str as $no) {
if ($no == $value || strtolower($no) == strtolower($value)) {
return $return;
}
}
}
}