예제 #1
0
 public function formatDateSpanData()
 {
     $time = 1416916800;
     // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
     $deL10N = new \OC_L10N('lib', 'de');
     return array(array('today', $this->getTimestampAgo($time, 30, 15), $time), array('yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time), array('4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time), array('5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time), array('2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time), array('today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array($deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), array($deL10N->t('yesterday'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), array($deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), array($deL10N->n('%n month ago', '%n months ago', 9), new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), array($deL10N->n('%n year ago', '%n years ago', 2), new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), array('today', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('today', new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('today', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Mon, 31 Dec 2012 00:00:00 +0000'), new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000')), array('2 days ago', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 31 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Thu, 31 Oct 2013 00:00:00 +0000')), array('9 months ago', new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('11 months ago', new \DateTime('Thu, 03 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('last year', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('last year', new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('2 years ago', new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')));
 }
예제 #2
0
 public function testCzechPluralTranslations()
 {
     $l = new OC_L10N('test');
     $transFile = OC::$SERVERROOT . '/tests/data/l10n/cs.json';
     $l->load($transFile);
     $this->assertEquals('1 okno', (string) $l->n('%n window', '%n windows', 1));
     $this->assertEquals('2 okna', (string) $l->n('%n window', '%n windows', 2));
     $this->assertEquals('5 oken', (string) $l->n('%n window', '%n windows', 5));
 }
예제 #3
0
 /**
  * Returns a list of grouped parameters
  *
  * 2 parameters are joined by "and":
  * => A and B
  * Up to 5 parameters are joined by "," and "and":
  * => A, B, C, D and E
  * More than 5 parameters are joined by "," and trimmed:
  * => A, B, C and #n more
  *
  * @param array $parameterList
  * @param array $plainParameterList
  * @param bool $highlightParams
  * @return string
  */
 protected function joinParameterList($parameterList, $plainParameterList, $highlightParams)
 {
     if (empty($parameterList)) {
         return '';
     }
     $count = sizeof($parameterList);
     $lastItem = array_pop($parameterList);
     if ($count == 1) {
         return $lastItem;
     } else {
         if ($count == 2) {
             $firstItem = array_pop($parameterList);
             return $this->l->t('%s and %s', array($firstItem, $lastItem));
         } else {
             if ($count <= 5) {
                 $list = implode($this->l->t(', '), $parameterList);
                 return $this->l->t('%s and %s', array($list, $lastItem));
             }
         }
     }
     $firstParams = array_slice($parameterList, 0, 3);
     $firstList = implode($this->l->t(', '), $firstParams);
     $trimmedParams = array_slice($plainParameterList, 3);
     $trimmedList = implode($this->l->t(', '), $trimmedParams);
     if ($highlightParams) {
         return $this->l->n('%s and <strong class="tooltip" title="%s">%n more</strong>', '%s and <strong class="tooltip" title="%s">%n more</strong>', $count - 3, array($firstList, $trimmedList));
     }
     return $this->l->n('%s and %n more', '%s and %n more', $count - 3, array($firstList));
 }