Exemple #1
0
 /**
  * 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 = IfwPsn_Vendor_Zend_Locale::getTranslation($question, 'question', $locale);
     $str = explode(':', $str);
     if (!empty($str)) {
         foreach ($str as $no) {
             if ($no == $value || strtolower($no) == strtolower($value)) {
                 return $return;
             }
         }
     }
 }
Exemple #2
0
 /**
  * Sets the locale to use
  *
  * @param string|IfwPsn_Vendor_Zend_Locale $locale
  * @throws IfwPsn_Vendor_Zend_Validate_Exception On unrecognised region
  * @throws IfwPsn_Vendor_Zend_Validate_Exception On not detected format
  * @return IfwPsn_Vendor_Zend_Validate_PostCode  Provides fluid interface
  */
 public function setLocale($locale = null)
 {
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Locale.php';
     $this->_locale = IfwPsn_Vendor_Zend_Locale::findLocale($locale);
     $locale = new IfwPsn_Vendor_Zend_Locale($this->_locale);
     $region = $locale->getRegion();
     if (empty($region)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Exception.php';
         throw new IfwPsn_Vendor_Zend_Validate_Exception("Unable to detect a region for the locale '{$locale}'");
     }
     $format = IfwPsn_Vendor_Zend_Locale::getTranslation($locale->getRegion(), 'postaltoterritory', $this->_locale);
     if (empty($format)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Exception.php';
         throw new IfwPsn_Vendor_Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
     }
     $this->setFormat($format);
     return $this;
 }