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


PHP App::setLocale方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Session::has('applocale') and array_key_exists(Session::get('applocale'), Config::get('languages'))) {
         App::setLocale(Session::get('applocale'));
     }
     return $next($request);
 }
开发者ID:bobbylinux,项目名称:HolisticRemedies,代码行数:14,代码来源:Language.php

示例2: index

 public function index($local = 'fa')
 {
     App::setLocale($local);
     $news = News::orderBy('id', 'Desc')->take(4)->get();
     //dd($news);
     return view('main.index', compact('news'));
 }
开发者ID:slifer2015,项目名称:tarabar,代码行数:7,代码来源:IndexController.php

示例3: relocate

 public function relocate($lang = null)
 {
     if ($lang != null) {
         App::setLocale($lang);
     }
     return View::make("cms::layouts.home");
 }
开发者ID:sirgrimorum,项目名称:laravel-cms,代码行数:7,代码来源:AdminTransController.php

示例4: setSupportedLanguage

 /**
  * @param string $lang
  */
 private function setSupportedLanguage($lang)
 {
     if ($this->isLanguageSupported($lang)) {
         App::setLocale($lang);
         Session::put('lang', $lang);
     }
 }
开发者ID:Tjoosten,项目名称:refugee,代码行数:10,代码来源:Language.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $language = Session::get('language', 'en');
     //en will be the default language.
     App::setLocale($language);
     return $next($request);
 }
开发者ID:kriminal666,项目名称:crimibook,代码行数:14,代码来源:BeforeSetLanguage.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = $request->segment(1);
     App::setLocale($locale);
     //dd(App::getLocale());
     return $next($request);
 }
开发者ID:ruslankus,项目名称:lavarel-lessons,代码行数:14,代码来源:SetLng.php

示例7: defineLocale

 /**
  *
  */
 private function defineLocale()
 {
     $tld = $this->getTld();
     if (array_key_exists($tld, $this->config['localesByTld'])) {
         App::setLocale($this->config['localesByTld'][$tld]);
     }
 }
开发者ID:bastiendonjon,项目名称:laravel-domain-localization,代码行数:10,代码来源:DomainLocalization.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // set app locale
     config(['app.locale' => auth('pulsar')->user()->lang_id_010]);
     // change app locale
     App::setLocale(auth('pulsar')->user()->lang_id_010);
     return $next($request);
 }
开发者ID:syscover,项目名称:pulsar,代码行数:15,代码来源:Locale.php

示例9: handle

 public function handle($request, Closure $next)
 {
     $lang = $request->cookie('language');
     if (!empty($lang)) {
         App::setLocale($lang);
     }
     return $next($request);
 }
开发者ID:LinaSakarne,项目名称:teikasmuzikanti,代码行数:8,代码来源:LanguageMiddleware.php

示例10: changeLanguage

 /**
  * Change app language
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function changeLanguage()
 {
     $language = Input::get('lang');
     //lang is name of form select field.
     Session::put('language', $language);
     App::setLocale($language);
     return back();
 }
开发者ID:kriminal666,项目名称:crimibook,代码行数:13,代码来源:HomeController.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $domain = Request::getHost();
     $locales = config('domains');
     if (in_array($domain, $locales)) {
         App::setLocale(array_search(Request::getHost(), $locales));
     }
     return $next($request);
 }
开发者ID:Alroniks,项目名称:klimchuk.com,代码行数:16,代码来源:Locale.php

示例12: setupLayout

 /**
  * Setup the layout used by the controller.
  *
  * @return void
  */
 protected function setupLayout()
 {
     App::setLocale('zh-CN');
     if (!is_null($this->layout)) {
         $this->layout = View::make($this->layout);
         $this->layout->page = false;
         $this->layout->dashboard = false;
     }
 }
开发者ID:bytrix,项目名称:witkey,代码行数:14,代码来源:AdminController.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  Request $request
  * @param  Closure $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $lang = Input::get('lang') ?: Config::get('app.locale');
     if (!preg_match('#[a-z]{2}#', $lang)) {
         $lang = Config::get('app.locale');
     }
     App::setLocale($lang);
     return $next($request);
 }
开发者ID:rolice,项目名称:speedy,代码行数:16,代码来源:Speedy.php

示例14: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //todo: fix it
     session_start();
     if (!isset($_SESSION['lang'])) {
         $_SESSION['lang'] = 'en';
     }
     App::setLocale($_SESSION['lang']);
 }
开发者ID:dosim88,项目名称:alexresume,代码行数:14,代码来源:AppServiceProvider.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::guest()) {
         // if the user is logged in we can set the prefered locale
         App::setLocale(Auth::user()->locale);
     }
     // otherwise we have to determine the current location or just keep fallback locale?
     return $next($request);
 }
开发者ID:vainproject,项目名称:vain,代码行数:17,代码来源:LoadUserLocale.php


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