当前位置: 首页>>代码示例>>PHP>>正文


PHP __dn函数代码示例

本文整理汇总了PHP中__dn函数的典型用法代码示例。如果您正苦于以下问题:PHP __dn函数的具体用法?PHP __dn怎么用?PHP __dn使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了__dn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param \Cake\ORM\Entity $entity Entity
  * @param int $code code to report to client
  */
 public function __construct(Entity $entity, $code = 422)
 {
     $this->_validationErrors = array_filter((array) $entity->errors());
     $flat = Hash::flatten($this->_validationErrors);
     $errorCount = $this->_validationErrorCount = count($flat);
     $this->message = __dn('crud', 'A validation error occurred', '{0} validation errors occurred', $errorCount, [$errorCount]);
     parent::__construct($this->message, $code);
 }
开发者ID:AmuseXperience,项目名称:api,代码行数:14,代码来源:ValidationException.php

示例2: __construct

 /**
  * Constructor
  *
  * @param array $error list of validation errors
  * @param integer $code code to report to client
  * @return void
  */
 public function __construct($errors, $code = 412)
 {
     $this->_validationErrors = array_filter($errors);
     $flat = Hash::flatten($this->_validationErrors);
     $errorCount = $this->_validationErrorCount = count($flat);
     $this->message = __dn('crud', 'A validation error occurred', '%d validation errors occurred', $errorCount, array($errorCount));
     if ($errorCount === 1) {
         $code = $this->_deriveRuleSpecific($this->_validationErrors, $code);
     }
     parent::__construct($this->message, $code);
 }
开发者ID:linking-arts,项目名称:furry-goggles,代码行数:18,代码来源:CrudValidationException.php

示例3: toReadableSize

 public function toReadableSize($size)
 {
     switch (true) {
         case $size < 1000:
             return __dn('cake', '{0,number,integer}', '{0,number,integer}', $size, $size);
         case round($size / 1000) < 1000:
             return __d('cake', '{0,number,#,###.##}k', $size / 1000);
         case round($size / 1000 / 1000, 2) < 1000:
             return __d('cake', '{0,number,#,###.##}m', $size / 1000 / 1000);
         case round($size / 1000 / 1000 / 1000, 2) < 1000:
             return __d('cake', '{0,number,#,###.##}b', $size / 1000 / 1000 / 1000);
         default:
             return __d('cake', '{0,number,#,###.##}t', $size / 1000 / 1000 / 1000 / 1000);
     }
 }
开发者ID:Cylindric,项目名称:edge,代码行数:15,代码来源:RpgNumberHelper.php

示例4: toReadableSize

 /**
  * Returns a formatted-for-humans file size.
  *
  * @param int $size Size in bytes
  * @return string Human readable size
  * @link http://book.cakephp.org/3.0/en/core-libraries/number.html#interacting-with-human-readable-values
  */
 public static function toReadableSize($size)
 {
     switch (true) {
         case $size < 1024:
             return __dn('cake', '{0,number,integer} Byte', '{0,number,integer} Bytes', $size, $size);
         case round($size / 1024) < 1024:
             return __d('cake', '{0,number,#,###.##} KB', $size / 1024);
         case round($size / 1024 / 1024, 2) < 1024:
             return __d('cake', '{0,number,#,###.##} MB', $size / 1024 / 1024);
         case round($size / 1024 / 1024 / 1024, 2) < 1024:
             return __d('cake', '{0,number,#,###.##} GB', $size / 1024 / 1024 / 1024);
         default:
             return __d('cake', '{0,number,#,###.##} TB', $size / 1024 / 1024 / 1024 / 1024);
     }
 }
开发者ID:yao-dev,项目名称:blog-mvc.github.io,代码行数:22,代码来源:Number.php

示例5: toReadableSize

 /**
  * Returns a formatted-for-humans file size.
  *
  * @param integer $size Size in bytes
  * @return string Human readable size
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::toReadableSize
  */
 public static function toReadableSize($size)
 {
     switch (true) {
         case $size < 1024:
             return __dn('cake', '%d Byte', '%d Bytes', $size, $size);
         case round($size / 1024) < 1024:
             return __d('cake', '%d KB', self::precision($size / 1024, 0));
         case round($size / 1024 / 1024, 2) < 1024:
             return __d('cake', '%.2f MB', self::precision($size / 1024 / 1024, 2));
         case round($size / 1024 / 1024 / 1024, 2) < 1024:
             return __d('cake', '%.2f GB', self::precision($size / 1024 / 1024 / 1024, 2));
         default:
             return __d('cake', '%.2f TB', self::precision($size / 1024 / 1024 / 1024 / 1024, 2));
     }
 }
开发者ID:sanyaade-machine-learning,项目名称:Catool,代码行数:22,代码来源:CakeNumber.php

示例6: toReadableSize

 /**
  * Returns a formatted-for-humans file size.
  *
  * @param integer $size Size in bytes
  * @return string Human readable size
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::toReadableSize
  */
 public function toReadableSize($size)
 {
     switch (true) {
         case $size < 1024:
             return __dn('cake', '%d Byte', '%d Bytes', $size, $size);
         case round($size / 1024) < 1024:
             return __d('cake', '%s KB', $this->precision($size / 1024, 0));
         case round($size / 1024 / 1024, 2) < 1024:
             return __d('cake', '%s MB', $this->precision($size / 1024 / 1024, 2));
         case round($size / 1024 / 1024 / 1024, 2) < 1024:
             return __d('cake', '%s GB', $this->precision($size / 1024 / 1024 / 1024, 2));
         default:
             return __d('cake', '%s TB', $this->precision($size / 1024 / 1024 / 1024 / 1024, 2));
     }
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:22,代码来源:NumberHelper.php

示例7: display

 public function display($likes, $userKey = 'username')
 {
     $n = count($likes);
     if ($n > 0) {
         if ($n == 1) {
             $like = $likes[0];
             $text = $this->Html->link($like['User'][$userKey], array('controller' => 'users', 'action' => 'view', $like['User']['id']));
         } else {
             if ($n > 1) {
                 $users = array();
                 foreach ($likes as $like) {
                     $users[] = $like['User'][$userKey];
                 }
                 $text = $this->Html->link(__n('%s people', '%s people', $n, $n), '#', array('title' => $this->Text->toList($users, __('and'))));
             }
         }
         echo __dn('like', '%s liked this.', '%s liked this.', $n, $text);
     }
 }
开发者ID:sharminas,项目名称:BlogAppTest,代码行数:19,代码来源:LikeHelper.php

示例8: clean

 /**
  * Re-builds the table
  *
  * @return void
  */
 public function clean()
 {
     //        $done = [];
     $errors = 0;
     if ($this->request->is('POST')) {
         // Get connection:
         $connection = ConnectionManager::get('default');
         $truncate = $connection->query('truncate acts;');
         $models = ['Files', 'Posts', 'Projects', 'Notes', 'Albums'];
         foreach ($models as $model) {
             //                $done[$model]=['add'=>0, 'edit'=>0];
             $query = $this->{$model}->find('all', ['conditions' => ['status' => 1]]);
             foreach ($query as $item) {
                 // Add
                 $act = $this->Acts->patchEntity($this->Acts->newEntity(), ['fkid' => $item->id, 'model' => $model, 'type' => 'add', 'created' => $item->created]);
                 //, 'user_id' => $uid]);
                 if (!$this->Acts->save($act)) {
                     $errors++;
                 }
                 //                    $done[$model]['add']++;
                 // Edit
                 if ($item->created != $item->modified) {
                     //                        $done[$model]['edit']++;
                     $act = $this->Acts->patchEntity($this->Acts->newEntity(), ['fkid' => $item->id, 'model' => $model, 'type' => 'edit', 'created' => $item->modified]);
                     //, 'user_id' => $uid]);
                     if (!$this->Acts->save($act)) {
                         $errors++;
                     }
                 }
             }
         }
         //            debug($done);die;
         if ($errors > 0) {
             $this->Flash->error(__dn('elabs', 'An error occured during the cleanup. Please, try again.', '{0,number} errors occured during the cleanup. Please, try again.', $errors, $errors));
         } else {
             $this->Flash->success(__d('elabs', 'Acts table has been rebuilt.'));
         }
         $this->redirect($this->request->referer());
     } else {
         throw new \Cake\Network\Exception\MethodNotAllowedException(__d('elabs', 'Use the menu to access this functionality'));
     }
 }
开发者ID:el-cms,项目名称:elabs,代码行数:47,代码来源:ActsController.php

示例9: load

 public function load()
 {
     $this->Product->clearCart();
     $products = array();
     foreach ($this->request->query as $parameter => $value) {
         if (strpos($parameter, 'product-') !== 0) {
             continue;
         }
         $products[(int) substr($parameter, 8)] = (int) $value;
     }
     $existingProducts = $this->Product->find('list', array('conditions' => array('Product.id' => array_keys($products))));
     foreach ($existingProducts as $productId => $name) {
         $this->Product->addToCart($productId, $products[$productId]);
     }
     if (empty($missingProducts)) {
         $this->Session->setFlash(__d('webshop_shopping_cart', 'The shopping cart has been imported'));
     } else {
         $this->Session->setFlash(__dn('webshop_shopping_cart', 'The shopping cart has been imported, the products with the following ids\'s did not exist however: %1$s', 'The shopping cart has been imported, the product with the following id did not exist however: %1$s', count($missingProducts), implode(', ', array_diff(array_keys($products), array_keys($existingProducts)))));
     }
     $this->redirect(array('action' => 'index'));
 }
开发者ID:cvo-technologies,项目名称:croogo-webshop-shopping-cart-plugin,代码行数:21,代码来源:ShoppingCartController.php

示例10: dateAgoInWords

 /**
  * Format a into a relative date string.
  *
  * @param \DatetimeInterface $date The date to format.
  * @param array $options Array of options.
  * @return string Relative date string.
  * @see \Cake\I18n\Date::timeAgoInWords()
  */
 public function dateAgoInWords(DatetimeInterface $date, array $options = [])
 {
     $options = $this->_options($options, FrozenDate::class);
     if ($options['timezone']) {
         $date = $date->timezone($options['timezone']);
     }
     $now = $options['from']->format('U');
     $inSeconds = $date->format('U');
     $backwards = $inSeconds > $now;
     $futureTime = $now;
     $pastTime = $inSeconds;
     if ($backwards) {
         $futureTime = $inSeconds;
         $pastTime = $now;
     }
     $diff = $futureTime - $pastTime;
     if (!$diff) {
         return __d('cake', 'today');
     }
     if ($diff > abs($now - (new FrozenDate($options['end']))->format('U'))) {
         return sprintf($options['absoluteString'], $date->i18nFormat($options['format']));
     }
     $diffData = $this->_diffData($futureTime, $pastTime, $backwards, $options);
     list($fNum, $fWord, $years, $months, $weeks, $days, $hours, $minutes, $seconds) = array_values($diffData);
     $relativeDate = [];
     if ($fNum >= 1 && $years > 0) {
         $relativeDate[] = __dn('cake', '{0} year', '{0} years', $years, $years);
     }
     if ($fNum >= 2 && $months > 0) {
         $relativeDate[] = __dn('cake', '{0} month', '{0} months', $months, $months);
     }
     if ($fNum >= 3 && $weeks > 0) {
         $relativeDate[] = __dn('cake', '{0} week', '{0} weeks', $weeks, $weeks);
     }
     if ($fNum >= 4 && $days > 0) {
         $relativeDate[] = __dn('cake', '{0} day', '{0} days', $days, $days);
     }
     $relativeDate = implode(', ', $relativeDate);
     // When time has passed
     if (!$backwards) {
         $aboutAgo = ['day' => __d('cake', 'about a day ago'), 'week' => __d('cake', 'about a week ago'), 'month' => __d('cake', 'about a month ago'), 'year' => __d('cake', 'about a year ago')];
         return $relativeDate ? sprintf($options['relativeString'], $relativeDate) : $aboutAgo[$fWord];
     }
     // When time is to come
     if ($relativeDate) {
         return $relativeDate;
     }
     $aboutIn = ['day' => __d('cake', 'in about a day'), 'week' => __d('cake', 'in about a week'), 'month' => __d('cake', 'in about a month'), 'year' => __d('cake', 'in about a year')];
     return $aboutIn[$fWord];
 }
开发者ID:raguilar0,项目名称:TCU_FEUCR,代码行数:58,代码来源:RelativeTimeFormatter.php

示例11: removeExpired

 /**
  * Removes expired registrations
  *
  * @return void
  */
 public function removeExpired()
 {
     $count = $this->UserTable->removeExpiredRegistrations();
     $this->out(__dn('user_tools', 'Removed {0,number,integer} expired registration.', 'Removed {0,number,integer} expired registrations.', $count, $count));
 }
开发者ID:tiagocapelli,项目名称:cakephp-user-tools,代码行数:10,代码来源:UserShell.php

示例12: testSubstitutionPluralDomain

 /**
  * testSubstitutionPluralDomain
  *
  * @return void
  */
 public function testSubstitutionPluralDomain()
 {
     $return = __dn('testing', 'single', 'plural {number}', 1);
     $this->assertSame('single', $return);
     $return = __dn('testing', 'single', 'plural {number}', 0);
     $this->assertSame('plural 0', $return);
     $return = __dn('testing', 'single', 'plural {number}', 2);
     $this->assertSame('plural 2', $return);
     $return = __dn('testing', 'single {color}', 'plural {number} {color}', 1, array('color' => 'blue'));
     $this->assertSame('single blue', $return);
     $return = __dn('testing', 'single {color}', 'plural {number} {color}', 0, array('color' => 'blue'));
     $this->assertSame('plural 0 blue', $return);
     $return = __dn('testing', 'single {color}', 'plural {number} {color}', 2, array('color' => 'blue'));
     $this->assertSame('plural 2 blue', $return);
 }
开发者ID:nodesagency,项目名称:Translations,代码行数:20,代码来源:OverrideI18nTest.php

示例13: timeAgoInWords


//.........这里部分代码省略.........
         return sprintf($absoluteString, $date);
     }
     $years = $months = $weeks = $days = $hours = $minutes = $seconds = 0;
     // If more than a week, then take into account the length of months
     if ($diff >= 604800) {
         list($future['H'], $future['i'], $future['s'], $future['d'], $future['m'], $future['Y']) = explode('/', date('H/i/s/d/m/Y', $endTime));
         list($past['H'], $past['i'], $past['s'], $past['d'], $past['m'], $past['Y']) = explode('/', date('H/i/s/d/m/Y', $startTime));
         $years = $future['Y'] - $past['Y'];
         $months = $future['m'] + (12 * $years - $past['m']);
         if ($months >= 12) {
             $years = floor($months / 12);
             $months = $months - $years * 12;
         }
         if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] === 1) {
             $years--;
         }
         if ($future['d'] >= $past['d']) {
             $days = $future['d'] - $past['d'];
         } else {
             $daysInPastMonth = date('t', $startTime);
             $daysInFutureMonth = date('t', mktime(0, 0, 0, $future['m'] - 1, 1, $future['Y']));
             if ($isFuture) {
                 $days = $daysInFutureMonth - $past['d'] + $future['d'];
             } else {
                 $days = $daysInPastMonth - $past['d'] + $future['d'];
             }
             if ($future['m'] != $past['m']) {
                 $months--;
             }
         }
         if (!$months && $years >= 1 && $diff < $years * 31536000) {
             $months = 11;
             $years--;
         }
         if ($months >= 12) {
             $years = $years + 1;
             $months = $months - 12;
         }
         if ($days >= 7) {
             $weeks = floor($days / 7);
             $days = $days - $weeks * 7;
         }
     } else {
         $days = floor($diff / 86400);
         $diff = $diff - $days * 86400;
         $hours = floor($diff / 3600);
         $diff = $diff - $hours * 3600;
         $minutes = floor($diff / 60);
         $diff = $diff - $minutes * 60;
         $seconds = $diff;
     }
     $accuracy = $accuracies['second'];
     if ($years > 0) {
         $accuracy = $accuracies['year'];
     } elseif (abs($months) > 0) {
         $accuracy = $accuracies['month'];
     } elseif (abs($weeks) > 0) {
         $accuracy = $accuracies['week'];
     } elseif (abs($days) > 0) {
         $accuracy = $accuracies['day'];
     } elseif (abs($hours) > 0) {
         $accuracy = $accuracies['hour'];
     } elseif (abs($minutes) > 0) {
         $accuracy = $accuracies['minute'];
     }
     $accuracyNum = str_replace(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second'), array(1, 2, 3, 4, 5, 6, 7), $accuracy);
     $relativeDate = array();
     if ($accuracyNum >= 1 && $years > 0) {
         $relativeDate[] = __dn('cake', '%d year', '%d years', $years, $years);
     }
     if ($accuracyNum >= 2 && $months > 0) {
         $relativeDate[] = __dn('cake', '%d month', '%d months', $months, $months);
     }
     if ($accuracyNum >= 3 && $weeks > 0) {
         $relativeDate[] = __dn('cake', '%d week', '%d weeks', $weeks, $weeks);
     }
     if ($accuracyNum >= 4 && $days > 0) {
         $relativeDate[] = __dn('cake', '%d day', '%d days', $days, $days);
     }
     if ($accuracyNum >= 5 && $hours > 0) {
         $relativeDate[] = __dn('cake', '%d hour', '%d hours', $hours, $hours);
     }
     if ($accuracyNum >= 6 && $minutes > 0) {
         $relativeDate[] = __dn('cake', '%d minute', '%d minutes', $minutes, $minutes);
     }
     if ($accuracyNum >= 7 && $seconds > 0) {
         $relativeDate[] = __dn('cake', '%d second', '%d seconds', $seconds, $seconds);
     }
     $relativeDate = implode(', ', $relativeDate);
     if ($relativeDate) {
         $relativeString = $isFuture ? $relativeStringFuture : $relativeStringPast;
         return sprintf($relativeString, $relativeDate);
     }
     if ($isFuture) {
         $strings = array('second' => __d('cake', 'in about a second'), 'minute' => __d('cake', 'in about a minute'), 'hour' => __d('cake', 'in about an hour'), 'day' => __d('cake', 'in about a day'), 'week' => __d('cake', 'in about a week'), 'year' => __d('cake', 'in about a year'));
     } else {
         $strings = array('second' => __d('cake', 'about a second ago'), 'minute' => __d('cake', 'about a minute ago'), 'hour' => __d('cake', 'about an hour ago'), 'day' => __d('cake', 'about a day ago'), 'week' => __d('cake', 'about a week ago'), 'year' => __d('cake', 'about a year ago'));
     }
     return $strings[$accuracy];
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:101,代码来源:CakeTime.php

示例14: testBasicDomainPluralFunction

 /**
  * Tests the __dn() function
  *
  * @return void
  */
 public function testBasicDomainPluralFunction()
 {
     I18n::translator('custom', 'en_US', function () {
         $package = new Package('default');
         $package->setMessages(['Cow' => 'Le Moo', 'Cows' => ['Le Moo', 'Les Moos']]);
         return $package;
     });
     $this->assertEquals('Le Moo', __dn('custom', 'Cow', 'Cows', 1));
     $this->assertEquals('Les Moos', __dn('custom', 'Cow', 'Cows', 2));
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:15,代码来源:I18nTest.php

示例15: __domainPlural

	/**
	 * Plural method
	 *
	 * @access private
	 * @return void
	 */
	function __domainPlural($domain = 'test_plugin') {
		$plurals = array();
		for ($number = 0; $number <= 25; $number++) {
			$plurals[] =  sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
		}
		return $plurals;
	}
开发者ID:ralmeida,项目名称:FoundFree.org,代码行数:13,代码来源:i18n.test.php


注:本文中的__dn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。