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


PHP Translator::choice方法代码示例

本文整理汇总了PHP中Illuminate\Translation\Translator::choice方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::choice方法的具体用法?PHP Translator::choice怎么用?PHP Translator::choice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Translation\Translator的用法示例。


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

示例1: age

 /**
  * Calculate age for given timestamp(s)
  *
  * @param  mixed $timestamp1  accepts string, unix-timestamp and DateTime object
  * @param  mixed $timestamp2  accepts string, unix-timestamp and DateTime object
  * @param  string $unit       constraint output to a given unit
  * @return string
  */
 public function age($timestamp1, $timestamp2 = null, $unit = null)
 {
     $timestamp1 = is_numeric($timestamp1) ? '@' . intval($timestamp1) : $timestamp1;
     $timestamp1 = is_a($timestamp1, 'DateTime') ? $timestamp1 : new DateTime($timestamp1);
     $timestamp2 = is_numeric($timestamp2) ? '@' . intval($timestamp2) : $timestamp2;
     $timestamp2 = is_a($timestamp2, 'DateTime') ? $timestamp2 : new DateTime($timestamp2);
     if ($timestamp1 == $timestamp2) {
         return $this->translator->get($this->getTranslationKey('date.n0w'));
     }
     $diff = $timestamp1->diff($timestamp2);
     $total = array('year' => $diff->y, 'month' => $diff->m + $diff->y * 12, 'week' => floor($diff->days / 7), 'day' => $diff->days, 'hour' => $diff->h + $diff->days * 24, 'minute' => $diff->h + $diff->i + $diff->days * 24 * 60, 'second' => $diff->h + $diff->i + $diff->s + $diff->days * 24 * 60 * 60);
     if (is_null($unit)) {
         foreach ($total as $key => $value) {
             if ($value > 0) {
                 $lang_key = 'date.' . $key . '_choice';
                 $lang_key = $this->getTranslationKey($lang_key);
                 $unit = $this->translator->choice($lang_key, $value);
                 return $value . ' ' . $unit;
             }
         }
     } elseif (array_key_exists($unit, $total)) {
         $value = $total[$unit];
         $lang_key = 'date.' . $unit . '_choice';
         $lang_key = $this->getTranslationKey($lang_key);
         $unit = $this->translator->choice($lang_key, $value);
         return $value . ' ' . $unit;
     }
     throw new \InvalidArgumentException('Invalid argument in function call');
 }
开发者ID:intervention,项目名称:helper,代码行数:37,代码来源:Date.php

示例2: choice

 /**
  * Get a translation according to an integer value.
  *
  * @param  string  $key
  * @param  int     $number
  * @param  array   $replace
  * @param  string  $locale
  * @param  bool    $wrap
  *
  * @return string
  */
 public function choice($key, $number, array $replace = array(), $locale = null, $wrap = true)
 {
     if (!Lari18n::isActivated()) {
         return parent::choice($key, $number, $replace, $locale);
     }
     $line = $this->get($key, $replace, $locale = $locale ?: $this->locale, false);
     $replace['count'] = $number;
     $hasTodo = strpos($line, $this->lari18n->todo_translation_key) > -1;
     $chosen = $this->makeReplacements($this->getSelector()->choose($line, $number, $locale), $replace);
     // Reapply the todo_translation_key if needed
     $chosen = $hasTodo ? $this->lari18n->todo_translation_key . $chosen : $chosen;
     if ($wrap == false) {
         return $chosen;
     } else {
         return $this->lari18n->wrap($chosen, $key, $replace, $locale, $number, $wrap);
     }
 }
开发者ID:nicolasbeauvais,项目名称:lari18n,代码行数:28,代码来源:Translator.php

示例3: choice

 /**
  * Get a translation according to an integer value.
  *
  * @param string $key
  * @param int $number
  * @param array $replace
  * @param string $locale
  * @return string 
  * @static 
  */
 public static function choice($key, $number, $replace = array(), $locale = null)
 {
     return \Illuminate\Translation\Translator::choice($key, $number, $replace, $locale);
 }
开发者ID:satriashp,项目名称:tour,代码行数:14,代码来源:_ide_helper.php

示例4: choice

 /**
  * Get a translation according to an integer value.
  *
  * @param  string $key
  * @param  int    $number
  * @param  array  $replace
  * @param  string $locale
  *
  * @return string
  */
 public function choice($key, $number, array $replace = array(), $locale = null, $useDB = null)
 {
     if (!$this->suspendInPlaceEdit && $this->inPlaceEditing()) {
         return $this->get($key, $replace, $locale, $useDB);
     } else {
         if ($useDB !== null) {
             $oldUseDB = $this->useDB;
             $this->useDB = $useDB;
             $retVal = parent::choice($key, $number, $replace, $locale);
             $this->useDB = $oldUseDB;
             return $retVal;
         } else {
             return parent::choice($key, $number, $replace, $locale);
         }
     }
 }
开发者ID:kduma-archive,项目名称:laravel-translation-manager-1,代码行数:26,代码来源:Translator.php

示例5: choice

 /**
  * {@inheritdoc}
  *
  * @param  string  $key
  * @param  int     $number
  * @param  array   $replace
  * @param  string  $locale
  * @return string
  */
 public function choice($key, $number, array $replace = array(), $locale = null)
 {
     return $this->lang->choice($key, $number, $replace, $locale);
 }
开发者ID:realholgi,项目名称:cmsable,代码行数:13,代码来源:Translator.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $keep = (int) $this->argument('keep');
     $removedBackups = count($this->cleaner->removeOldBackups($keep));
     $this->info($this->translator->choice('backups.cleaned', $removedBackups, ['amount' => $removedBackups]));
 }
开发者ID:ricoa,项目名称:laravel.io,代码行数:11,代码来源:BackupCleanCommand.php

示例7: choice

 /**
  * Get a translation according to an integer value.
  *
  * @param  string $key
  * @param  int    $number
  * @param  array  $replace
  * @param  string $locale
  *
  * @return string
  */
 public function choice($key, $number, array $replace = array(), $locale = null, $useDB = null)
 {
     $inplaceEditMode = $this->manager->config('inplace_edit_mode');
     if ($this->inPlaceEditing() && $inplaceEditMode == 2) {
         if (!in_array($key, $this->usedKeys)) {
             $this->usedKeys[] = $key;
         }
     }
     if (!$this->suspendInPlaceEdit && $this->inPlaceEditing() && $inplaceEditMode == 1) {
         return $this->get($key, $replace, $locale, $useDB);
     } else {
         if ($useDB !== null) {
             $oldUseDB = $this->useDB;
             $this->useDB = $useDB;
             $retVal = parent::choice($key, $number, $replace, $locale);
             $this->useDB = $oldUseDB;
             return $retVal;
         } else {
             return parent::choice($key, $number, $replace, $locale);
         }
     }
 }
开发者ID:vsch,项目名称:laravel-translation-manager,代码行数:32,代码来源:Translator.php


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