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


PHP Translator::get方法代码示例

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


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

示例1: makeResponse

 protected function makeResponse(Request $request)
 {
     $message = $this->translator->get('c::auth.login-required');
     if ($request->ajax() || $request->isJson() || $request->wantsJson()) {
         return Response::json(['error' => $message], 403);
     } else {
         $url = $this->url->action('anlutro\\Core\\Web\\AuthController@login');
         $intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/');
         $this->session->put('url.intended', $intended);
         return $this->redirect->to($url)->with('error', $message);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:12,代码来源:AuthFilter.php

示例2: 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

示例3: __construct

 public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, Translator $Lang)
 {
     $this->DB = $DB;
     $this->AuthenticationManager = $AuthenticationManager;
     /*
     $this->Database = $DB->table('ACCT_Journal_Entry AS je')
     						->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
     						->rightJoin('ACCT_Account AS c', 'je.account_id', '=', 'c.id')
     						->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
     						->where(function($query)
     		                {
     		                  $query->orWhere('jv.status', '=', 'B');
     		                  $query->orWhereNull('jv.status');
     		                }
     						)
     						->where('c.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())
     						->whereIn('at.pl_bs_category', array('B', 'C'))
     						->whereNull('je.deleted_at')
     						->whereNull('jv.deleted_at');
     */
     $this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->rightJoin('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')->where('jv.status', '=', 'B')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereIn('at.pl_bs_category', array('B', 'C'))->whereNull('je.deleted_at')->whereNull('jv.deleted_at');
     $this->Database2 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Account AS c')->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')->where('c.is_group', '=', 1)->where('c.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->whereIn('at.pl_bs_category', array('B', 'C'))->select(array($DB->raw('0 AS acct_pl_debit'), $DB->raw('0 AS acct_pl_credit'), 'c.id AS acct_pl_account_id', 'c.parent_account_id AS acct_pl_parent_account_id', 'c.key AS acct_pl_account_key', 'c.name AS acct_pl_account_name', 'c.is_group AS acct_pl_is_group', 'c.balance_type AS acct_pl_balance_type', $DB->raw('CASE at.pl_bs_category WHEN "B" THEN "' . $Lang->get('decima-accounting::profit-and-loss.income') . '" ELSE "' . $Lang->get('decima-accounting::profit-and-loss.expenses') . '" END AS acct_pl_pl_bs_category'), $DB->raw('0 AS acct_pl_balance')));
     $this->visibleColumns = array($DB->raw('IFNULL(SUM(je.debit),0) AS acct_pl_debit'), $DB->raw('IFNULL(SUM(je.credit),0) AS acct_pl_credit'), 'c.id AS acct_pl_account_id', 'c.parent_account_id AS acct_pl_parent_account_id', 'c.key AS acct_pl_account_key', 'c.name AS acct_pl_account_name', 'c.is_group AS acct_pl_is_group', 'c.balance_type AS acct_pl_balance_type', $DB->raw('CASE at.pl_bs_category WHEN "B" THEN "' . $Lang->get('decima-accounting::profit-and-loss.income') . '" ELSE "' . $Lang->get('decima-accounting::profit-and-loss.expenses') . '" END AS acct_pl_pl_bs_category'), $DB->raw('0 AS acct_pl_balance'));
     $this->orderBy = array(array('acct_pl_account_key', 'asc'));
 }
开发者ID:mgallegos,项目名称:decima-accounting,代码行数:25,代码来源:EloquentProfitAndLossGridRepository.php

示例4: render

 /**
  * Render the likes into a string.
  *
  * @param Collection $likesCollection  The likes to render.
  *
  * @param string     $viewAllLikesLink The link to view all of the likes for the content.
  *
  * @return string
  */
 public function render(Collection $likesCollection, $viewAllLikesLink)
 {
     $numLikesToList = $this->settings->get('posts.likes_to_show', 3);
     $numOtherLikes = $likesCollection->count() - $numLikesToList;
     $userId = $this->guard->user()->getAuthIdentifier();
     $likes = [];
     $likesCollection = $likesCollection->filter(function (Like $like) use(&$likes, &$numLikesToList, $userId) {
         if ($like->user->id === $userId) {
             $like->user->name = $this->lang->get('likes.current_user');
             $likes[] = $like;
             $numLikesToList--;
             return false;
         }
         return true;
     });
     $numLikesInCollection = $likesCollection->count();
     if ($numLikesInCollection > 0 && $numLikesToList > 0) {
         if ($numLikesInCollection < $numLikesToList) {
             $numLikesToList = $numLikesInCollection;
         }
         $randomLikes = $likesCollection->random($numLikesToList);
         if (!is_array($randomLikes)) {
             // random returns a single model if $numLikesToList is 1...
             $randomLikes = array($randomLikes);
         }
         foreach ($randomLikes as $key => $like) {
             $likes[] = $like;
         }
     }
     return $this->viewFactory->make('likes.list', compact('numOtherLikes', 'likes', 'viewAllLikesLink'))->render();
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:40,代码来源:RenderLikes.php

示例5: __construct

 /**
  * @param \Illuminate\Translation\Translator         $translator
  * @param \Illuminate\Routing\Router                 $router
  * @param \Illuminate\Contracts\Routing\UrlGenerator $urlGenerator
  */
 public function __construct(Translator $translator, Router $router, UrlGenerator $urlGenerator)
 {
     $this->translator = $translator;
     $this->router = $router;
     $this->urlGenerator = $urlGenerator;
     // Unfortunately we can't do this in the service provider since routes are booted first
     $this->translator->addNamespace('paginateroute', __DIR__ . '/../resources/lang');
     $this->pageKeyword = $this->translator->get('paginateroute::paginateroute.page');
 }
开发者ID:hugofabricio,项目名称:laravel-paginateroute,代码行数:14,代码来源:PaginateRoute.php

示例6: update

 public function update()
 {
     $roles = $this->request->get('roles', []);
     try {
         $this->execute('Pardisan\\Commands\\Permission\\PermRoleCommand', ['roles' => $roles]);
         return $this->redirectRoute('admin.permissions.index')->with('success_message', $this->lang->get('messages.permissions.update_success'));
     } catch (RepositoryException $e) {
         return $this->redirectBack()->with('error_message', $this->lang->get('messages.repository_error'));
     }
 }
开发者ID:reshadman,项目名称:hammihan-online,代码行数:10,代码来源:PermissionController.php

示例7: __construct

 public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, Translator $Lang)
 {
     // $this->DB = $DB;
     // $this->DB->connection()->enableQueryLog();
     $this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Account AS a')->leftJoin('ACCT_Account AS ap', 'ap.id', '=', 'a.parent_account_id')->join('ACCT_Account_Type AS at', 'at.id', '=', 'a.account_type_id')->where('a.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->whereNull('a.deleted_at');
     $this->visibleColumns = array('a.id AS acct_am_id', 'a.key as acct_am_key', 'a.name as acct_am_name', 'a.balance_type as acct_am_balance_type', 'a.is_group as acct_am_is_group', 'a.account_type_id as acct_am_account_type_id', 'at.name as acct_am_account_type', 'ap.id as acct_am_parent_account_id', 'ap.key as acct_am_parent_key', 'ap.name as acct_am_parent_account', $DB->raw('CASE a.balance_type WHEN "D" THEN "' . $Lang->get('decima-accounting::account-management.D') . '" ELSE "' . $Lang->get('decima-accounting::account-management.A') . '" END AS acct_am_balance_type_name'), $DB->raw('CASE a.is_group WHEN 1 THEN 0 ELSE 1 END AS acct_am_is_leaf'));
     $this->orderBy = array(array('acct_am_key', 'asc'));
     $this->treeGrid = true;
     $this->parentColumn = 'ap.id';
     $this->leafColumn = 'acct_am_is_leaf';
 }
开发者ID:mgallegos,项目名称:decima-accounting,代码行数:11,代码来源:EloquentAccountGridRepository.php

示例8: agegate

 /**
  * Renders the age gate view
  */
 public function agegate()
 {
     $previousTooYoung = $this->session->get('laravel-avp.previous_too_young');
     $view = view(config('agegate.view'))->with(compact('previousTooYoung'));
     if (!$this->session->has('errors') && $previousTooYoung) {
         $messages = $this->lang->get('laravel-avp::validation.custom');
         $errorMsg = $messages['dob.previous'];
         $view->withErrors(['dob' => [$errorMsg]]);
     }
     return $view;
 }
开发者ID:fastwebmedia,项目名称:laravel-avp,代码行数:14,代码来源:AVPController.php

示例9: __construct

 public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, AccountManagementInterface $AccountManager, Translator $Lang, Carbon $Carbon)
 {
     $this->DB = $DB;
     $this->AccountManager = $AccountManager;
     $this->AuthenticationManager = $AuthenticationManager;
     $this->Carbon = $Carbon;
     $this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array($DB->raw('IFNULL(SUM(je.debit),0) AS acct_gl_debit'), $DB->raw('IFNULL(SUM(je.credit),0) AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', 'c.key AS acct_gl_account_key', 'c.name AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('0 AS acct_gl_total_debit'), $DB->raw('0 AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('\'\' AS acct_gl_voucher_date'), $DB->raw('\'\' AS acct_gl_voucher_type'), $DB->raw('\'\' AS acct_gl_voucher_number')));
     $this->Database2 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Account AS c')->where('c.is_group', '=', 1)->where('c.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->select(array($DB->raw('0 AS acct_gl_debit'), $DB->raw('0 AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', 'c.key AS acct_gl_account_key', 'c.name AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('0 AS acct_gl_total_debit'), $DB->raw('0 AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('\'\' AS acct_gl_voucher_date'), $DB->raw('\'\' AS acct_gl_voucher_type'), $DB->raw('\'\' AS acct_gl_voucher_number')));
     $this->Database3 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array($DB->raw('0 AS acct_gl_debit'), $DB->raw('0 AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', 'c.key AS acct_gl_account_key', 'c.name AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('IFNULL(SUM(je.debit),0) AS acct_gl_total_credit'), $DB->raw('IFNULL(SUM(je.credit),0) AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('\'\' AS acct_gl_voucher_date'), $DB->raw('\'\' AS acct_gl_voucher_type'), $DB->raw('\'\' AS acct_gl_voucher_number')));
     $this->Database4 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->join('ACCT_Voucher_Type AS vt', 'vt.id', '=', 'jv.voucher_type_id')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array($DB->raw('je.debit AS acct_gl_debit'), $DB->raw('je.credit AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', $DB->raw('IFNULL(jv.manual_reference,"' . $Lang->get('decima-accounting::journal-management.noRef') . '") AS acct_gl_account_key'), 'jv.remark AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('0 AS acct_gl_total_debit'), $DB->raw('0 AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('DATE_FORMAT(jv.date, "' . $Lang->get('form.mysqlDateFormat') . '") AS acct_gl_voucher_date'), $DB->raw('vt.name AS acct_gl_voucher_type'), $DB->raw('jv.number AS acct_gl_voucher_number')));
     $this->orderBy = array(array('acct_gl_account_key', 'asc'));
 }
开发者ID:mgallegos,项目名称:decima-accounting,代码行数:12,代码来源:EloquentGeneralLedgerGridRepository.php

示例10: trans

 public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
 {
     $id = "{$domain}.{$id}";
     $message = $this->translator->get($id, $parameters, $locale);
     if ($message == $id) {
         $message = str_replace($domain . ".", "", $message);
         foreach ($parameters as $key => $value) {
             $message = str_replace(':' . $key, $value, $message);
         }
     }
     return $message;
 }
开发者ID:Konuko,项目名称:twigStay,代码行数:12,代码来源:Translator.php

示例11: localized

 /**
  * Get localized name of zodiac sign
  *
  * @return string
  */
 public function localized()
 {
     if (!is_a($this->translator, 'Illuminate\\Translation\\Translator')) {
         return "zodiacs.{$this->name}";
     }
     if ($this->translator->has("zodiacs.{$this->name}")) {
         // return error message from validation translation file
         return $this->translator->get("zodiacs.{$this->name}");
     }
     // return packages default message
     return $this->translator->get("zodiacs::zodiacs.{$this->name}");
 }
开发者ID:Intervention,项目名称:zodiac,代码行数:17,代码来源:AbstractZodiac.php

示例12: store

 /**
  * @param SigninRequest $request
  * @param Translator $lang
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(SignInRequest $request, Translator $lang)
 {
     $credentials = $request->except('_token', 'remember_me');
     $remember_me = $request->has('remember_me') ? true : false;
     $response = $this->dispatch(new Signin($credentials, $remember_me));
     if ($response instanceof User) {
         return redirect('admin/start');
     } elseif (is_string($response) && $response == 'unconfirmed') {
         $route = store_route('store.auth.confirm-email.create', ['email' => $credentials['email']]);
         $error = $lang->get('users::auth.errors.unconfirmed', ['url' => $route]);
         return redirect()->back()->withErrors(['email' => $error]);
     }
     return redirect()->back()->withErrors(['email' => $lang->get('users::auth.errors.failed')]);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:19,代码来源:SigninController.php

示例13: last_page

 /**
  * @return string
  */
 public function last_page()
 {
     $lang = null;
     $collection = $this->router->getRoutes();
     $route = $collection->match(Request::create($this->wrappedObject->last_page));
     if ($route->getName() != null) {
         $langOptions = $this->getWioData($route->getName(), $route->parameters());
         if (!isset($langOptions['url'])) {
             $langOptions['url'] = route($route->getName(), $route->parameters());
         }
         if (!isset($langOptions['langString'])) {
             $langString = 'online.' . $route->getName();
         } else {
             $langString = 'online.' . $langOptions['langString'];
             unset($langOptions['langString']);
         }
         $lang = $this->translator->get($langString, $langOptions);
         // May happen if we have two routes 'xy.yx.zz' and 'xy.yx'
         if (is_array($lang)) {
             $lang = $this->translator->get($langString . '.index', $langOptions);
         }
     }
     if ($lang == null) {
         //			$lang = Lang::get('online.unknown', ['url' => '']);
         // Used for debugging, should be left here until we have added all routes
         $lang = 'online.' . $route->getName();
     }
     return $lang;
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:32,代码来源:User.php

示例14: shareTitle

 private function shareTitle()
 {
     $langKey = "titles.{$this->router->currentRouteName()}";
     if ($this->lang->has($langKey)) {
         $this->view->share('title', $this->lang->get($langKey));
     }
 }
开发者ID:reshadman,项目名称:hammihan-online,代码行数:7,代码来源:Settings.php

示例15: get

 /**
  * Get the translation for the given key.
  *
  * @param  string  $key
  * @param  array   $replace
  * @param  string  $locale
  * @param  bool    $wrap
  *
  * @return string
  */
 public function get($key, array $replace = array(), $locale = null, $wrap = true)
 {
     if (!Lari18n::isActivated() || !$wrap) {
         return parent::get($key, $replace, $locale);
     }
     return $this->lari18n->wrap(parent::get($key, $replace, $locale), $key, $replace, $locale);
 }
开发者ID:nicolasbeauvais,项目名称:lari18n,代码行数:17,代码来源:Translator.php


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