示例#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);
 }
示例#2
0
文件: Locale.php 项目: stunti/zf2
 /**
  * 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\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;
 }
示例#3
0
文件: Date.php 项目: bradley-holt/zf2
 /**
  * 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('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("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("unknown month name ({$month})", 0, null, $month);
                 }
             }
         }
     }
     $return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
     if ($calc != 'cmp') {
         return $this;
     }
     return $return;
 }