當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。