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


PHP Lang::choice方法代码示例

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


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

示例1: diffForHumans

 public function diffForHumans(Carbon $other = null)
 {
     $isNow = $other === null;
     if ($isNow) {
         $other = static::now($this->tz);
     }
     $isFuture = $this->gt($other);
     $delta = $other->diffInSeconds($this);
     // 4 weeks per month, 365 days per year... good enough!!
     $divs = array('second' => self::SECONDS_PER_MINUTE, 'minute' => self::MINUTES_PER_HOUR, 'hour' => self::HOURS_PER_DAY, 'day' => self::DAYS_PER_WEEK, 'week' => 4, 'month' => self::MONTHS_PER_YEAR);
     $unit = 'year';
     foreach ($divs as $divUnit => $divValue) {
         if ($delta < $divValue) {
             $unit = $divUnit;
             break;
         }
         $delta = floor($delta / $divValue);
     }
     if ($delta == 0) {
         $delta = 1;
     }
     // Código adaptado para utilizar el gestor de idiomas de Laravel
     $txt = 'carbonlocale';
     if ($isFuture) {
         return Lang::choice("{$txt}.future.{$unit}", $delta, compact('delta'));
     }
     return Lang::choice("{$txt}.past.{$unit}", $delta, compact('delta'));
 }
开发者ID:nelug,项目名称:ControlDePlanilla,代码行数:28,代码来源:CarbonLocale.php

示例2: pluginCallback

 public function pluginCallback()
 {
     $params = func_get_args();
     $value = array_shift($params);
     if (isset($params[0])) {
         return Lang::choice($value, $params[0]);
     }
     return Lang::get($value);
 }
开发者ID:imnotjames,项目名称:smartyview,代码行数:9,代码来源:Localize.php

示例3: presentReadableRuntime

 /**
  * Converts a number of seconds into a more human readable format.
  *
  * @param  int    $seconds The number of seconds
  * @return string
  */
 public function presentReadableRuntime()
 {
     if (!$this->object instanceof RuntimeInterface) {
         throw new \RuntimeException('Model must implement RuntimeInterface');
     }
     $seconds = $this->object->runtime();
     $units = ['week' => 7 * 24 * 3600, 'day' => 24 * 3600, 'hour' => 3600, 'minute' => 60, 'second' => 1];
     if ($seconds === 0) {
         return Lang::choice('deployments.second', 0, ['time' => 0]);
     }
     $readable = '';
     foreach ($units as $name => $divisor) {
         if ($quot = intval($seconds / $divisor)) {
             $readable .= Lang::choice('deployments.' . $name, $quot, ['time' => $quot]) . ', ';
             $seconds -= $quot * $divisor;
         }
     }
     return substr($readable, 0, -2);
 }
开发者ID:devLopez,项目名称:deployer-1,代码行数:25,代码来源:RuntimePresenter.php

示例4: verifyUser

 /**
  * Confirm the registration procedure through a code control
  *
  * @return \Illuminate\View\View
  *
  */
 public function verifyUser($code)
 {
     if (!$code) {
         $data['errore'] = true;
         $data['titolo'] = Lang::choice("messages.errore", 0);
         $data['conferma'] = Lang::choice('messages.errore_signin', 0);
         return view('auth.confirm', $data);
     }
     $user = $this->user->where('codice_conferma', '=', $code)->first();
     if (!$user) {
         $data['errore'] = true;
         $data['titolo'] = Lang::choice("messages.errore", 0);
         $data['conferma'] = Lang::choice('messages.errore_signin', 0);
         return view('auth.confirm', $data);
     } else {
         $user->confermato = true;
         $user->codice_conferma = null;
         $user->save();
         $data['conferma'] = Lang::choice('messages.conferma_testo', 0);
         $data['errore'] = false;
         $data['titolo'] = Lang::choice('messages.conferma_titolo', 0);
         return view('auth.confirm', $data);
     }
 }
开发者ID:abada,项目名称:HolisticRemedies,代码行数:30,代码来源:AuthController.php

示例5: NotifyUserForPlanExpire

 public function NotifyUserForPlanExpire()
 {
     $response = new ServiceResponse();
     $Plans = DB::select("SELECT pph.UserID, DATEDIFF(pph.EndDate, CURRENT_DATE()) AS TimeLeft, pph.PlanName FROM paymentplanshistory pph LEFT JOIN paymentplanshistory pph2 ON pph.UserID = pph2.UserID AND DATEDIFF(pph2.StartDate, pph.EndDate)=1\nWHERE pph.IsActive = 1 AND IFNULL(pph2.PaymentHistoryID,'') = '' AND DATEDIFF(pph.EndDate, CURRENT_DATE()) IN (0,3,5,7)");
     if ($Plans && count($Plans) > 0) {
         foreach ($Plans as $Plan) {
             $message = Lang::choice("messages.PlanWillExpireInDays", $Plan->TimeLeft, array("plan" => $Plan->PlanName, "day" => $Plan->TimeLeft));
             $userNotificationEntity = new UserNotificationEntity();
             $userNotificationEntity->Description = $message;
             $userNotificationEntity->UserID = $Plan->UserID;
             $userNotificationEntity->CreatedDate = date(Constants::$DefaultDateTimeFormat);
             $userNotificationEntity->save();
             $notificationEntity = new NotificationEntity();
             $notificationEntity->UserID = $Plan->UserID;
             $notificationEntity->NotificationType = Constants::$NotificationType['General'];
             $notificationEntity->Message = $message;
             $notificationEntity->CreatedDate = date(Constants::$DefaultDateTimeFormat);
             $notificationEntity->save();
         }
         $response->IsSuccess = true;
     }
     return $response;
 }
开发者ID:rohitbhalani,项目名称:RB_Test,代码行数:23,代码来源:PlanDataProvider.php

示例6: testChoice

 public function testChoice()
 {
     $this->assertEquals('Articles', Lang::choice('content::messages.article', 10, [], 'en'));
 }
开发者ID:newmarkets,项目名称:content,代码行数:4,代码来源:LocalizationTest.php

示例7: getLanguageHelpers

 /**
  * Get language helper functions.
  *
  * @return array
  */
 protected function getLanguageHelpers()
 {
     return ['lang' => function ($args, $named) {
         return Lang::get($args[0], $named);
     }, 'choice' => function ($args, $named) {
         return Lang::choice($args[0], $args[1], $named);
     }];
 }
开发者ID:proai,项目名称:laravel-handlebars,代码行数:13,代码来源:HandlebarsCompiler.php

示例8: compose

 public function compose($view)
 {
     $view->title = trans(Route::currentRouteName() . '_title');
     $view->text_total = Lang::choice('tickets.total', $view->tickets->total(), ['title' => strtolower($view->title)]);
 }
开发者ID:resand,项目名称:teachme,代码行数:5,代码来源:TicketsListComposer.php

示例9: getLanguageHelpers

 /**
  * Get language helper functions.
  *
  * @return array
  */
 protected function getLanguageHelpers()
 {
     return ['lang' => function ($args, $named) {
         return \Illuminate\Support\Facades\Lang::get($args[0], $named);
     }, 'choice' => function ($args, $named) {
         return \Illuminate\Support\Facades\Lang::choice($args[0], $args[1], $named);
     }];
 }
开发者ID:karriereat,项目名称:laravel-handlebars,代码行数:13,代码来源:HandlebarsCompiler.php

示例10: postCompensation

 public function postCompensation(Request $request)
 {
     if ($request->has('id') && $request->has('end_repair')) {
         $id = $request->get('id');
         $end_repair = str_replace('.', '-', $request->get('end_repair'));
         $end_repair = Carbon::parse($end_repair)->timestamp;
         $compensation = Compensation::find($id);
         if ($end_repair > $compensation->shift_end) {
             $end_repair = $compensation->shift_end;
         }
         if ($compensation->begin > $end_repair) {
             return 'Введенные данные не были правильны пожалуйста повторите';
         }
         $price_for_one_second = $compensation->shift_sum / ($compensation->shift_end - $compensation->shift_start);
         $in_repair_second = $end_repair - $compensation->begin;
         $sum = round($price_for_one_second * $in_repair_second, 2);
         $driver = Driver::getDriverInfoByCar($this->city->db, $compensation->gn);
         if (empty($driver)) {
             return 'Извините водитель не найден на такой машине';
         }
         //driver operations here
         $compensation->end = $end_repair;
         $compensation->save();
         $user = $request->user();
         $difference = Carbon::createFromTimestamp($end_repair)->diffInHours(Carbon::createFromTimestamp($compensation->begin));
         if ($difference == 0) {
             $difference = Carbon::createFromTimestamp($end_repair)->diffInMinutes(Carbon::createFromTimestamp($compensation->begin));
             $log_description = $user->name . " компенсировал водителю {$compensation->gn} за {$difference} мин";
         } else {
             $log_description = $this->getRole($user) . " " . $user->name . " компенсировал водителю {$compensation->gn} за {$difference} " . Lang::choice('message.times', $difference, [], 'ru');
         }
         $user->userLogs('compensation', $user->name, $log_description, $this->city->index);
         return "Компенсация в размере {$sum} за {$difference} часов";
     }
     return 'Извините произошла ошибка повторите позже';
 }
开发者ID:neolinks,项目名称:cabinet,代码行数:36,代码来源:PersonalController.php


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