本文整理汇总了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);
}
示例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'));
}
示例3: relocate
public function relocate($lang = null)
{
if ($lang != null) {
App::setLocale($lang);
}
return View::make("cms::layouts.home");
}
示例4: setSupportedLanguage
/**
* @param string $lang
*/
private function setSupportedLanguage($lang)
{
if ($this->isLanguageSupported($lang)) {
App::setLocale($lang);
Session::put('lang', $lang);
}
}
示例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);
}
示例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);
}
示例7: defineLocale
/**
*
*/
private function defineLocale()
{
$tld = $this->getTld();
if (array_key_exists($tld, $this->config['localesByTld'])) {
App::setLocale($this->config['localesByTld'][$tld]);
}
}
示例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);
}
示例9: handle
public function handle($request, Closure $next)
{
$lang = $request->cookie('language');
if (!empty($lang)) {
App::setLocale($lang);
}
return $next($request);
}
示例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();
}
示例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);
}
示例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;
}
}
示例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);
}
示例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']);
}
示例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);
}