Beispiel #1
0
 /**
  * test for reading intervalformat from locale
  * expected array
  */
 public function testUnit()
 {
     $value = Data::getList('de_AT', 'unit');
     $result = array('day' => array('one' => '{0} Tag', 'other' => '{0} Tage'), 'hour' => array('one' => '{0} Stunde', 'other' => '{0} Stunden'), 'minute' => array('one' => '{0} Minute', 'other' => '{0} Minuten'), 'month' => array('one' => '{0} Monat', 'other' => '{0} Monate'), 'second' => array('one' => '{0} Sekunde', 'other' => '{0} Sekunden'), 'week' => array('one' => '{0} Woche', 'other' => '{0} Wochen'), 'year' => array('one' => '{0} Jahr', 'other' => '{0} Jahre'));
     $this->assertEquals($result, $value);
     $value = Data::getContent('de_AT', 'unit', array('day', 'one'));
     $this->assertEquals('{0} Tag', $value);
 }
Beispiel #2
0
 /**
  * Returns the calculated month
  *
  * @param  string                          $calc    Calculation to make
  * @param  string|integer|array|\Zend\Date\Date  $month   Month to calculate with, if null the actual month is taken
  * @param  string|\Zend\Locale\Locale              $locale  Locale for parsing input
  * @return integer|\Zend\Date\Date  new time
  * @throws \Zend\Date\Exception
  */
 private function _month($calc, $month, $locale)
 {
     if ($month === null) {
         throw new Exception\InvalidArgumentException('parameter $month must be set, null is not allowed');
     }
     if ($locale === null) {
         $locale = $this->getLocale();
     }
     if ($month instanceof Date) {
         // extract month from object
         $found = $month->toString(self::MONTH_SHORT, 'iso', $locale);
     } else {
         if (is_numeric($month)) {
             $found = $month;
         } else {
             if (is_array($month)) {
                 if (isset($month['month']) === true) {
                     $month = $month['month'];
                 } else {
                     throw new Exception\InvalidArgumentException("no month given in array");
                 }
             } else {
                 $monthlist = Data::getList($locale, 'month');
                 $monthlist2 = Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
                 $monthlist = array_merge($monthlist, $monthlist2);
                 $found = 0;
                 $cnt = 0;
                 foreach ($monthlist as $key => $value) {
                     if (strtoupper($value) == strtoupper($month)) {
                         $found = $key % 12 + 1;
                         break;
                     }
                     ++$cnt;
                 }
                 if ($found == 0) {
                     foreach ($monthlist2 as $key => $value) {
                         if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($month)) {
                             $found = $key + 1;
                             break;
                         }
                         ++$cnt;
                     }
                 }
                 if ($found == 0) {
                     throw new Exception\InvalidArgumentException("unknown month name ({$month})");
                 }
             }
         }
     }
     $return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
     if ($calc != 'cmp') {
         return $this;
     }
     return $return;
 }
Beispiel #3
0
 /**
  * Returns a list of currencies which are used in this region
  * a region name should be 2 charachters only (f.e. EG, DE, US)
  * If no region is given, the actual region is used
  *
  * @param  string $region OPTIONAL Region to return the currencies for
  * @return array List of currencies
  */
 public function getCurrencyList($region = null)
 {
     if (empty($region) === true) {
         if (strlen($this->_options['locale']) > 4) {
             $region = substr($this->_options['locale'], strpos($this->_options['locale'], '_') + 1);
         }
     }
     return Data::getList('', 'regiontocurrency', $region);
 }
Beispiel #4
0
 /**
  * Returns an array with translated yes strings
  *
  * @param  string|\Zend\Locale\Locale $locale (Optional) Locale for language translation (defaults to $this locale)
  * @return array
  */
 public static function getQuestion($locale = null)
 {
     $locale = self::findLocale($locale);
     $quest = Data::getList($locale, 'question');
     $yes = explode(':', $quest['yes']);
     $no = explode(':', $quest['no']);
     $quest['yes'] = $yes[0];
     $quest['yesarray'] = $yes;
     $quest['no'] = $no[0];
     $quest['noarray'] = $no;
     $quest['yesexpr'] = self::_prepareQuestionString($yes);
     $quest['noexpr'] = self::_prepareQuestionString($no);
     return $quest;
 }