Commit d56c9620 by Aan Choesni Herlingga

first step change language

parent f24cb7f1
...@@ -25,4 +25,12 @@ class HomeController extends Controller ...@@ -25,4 +25,12 @@ class HomeController extends Controller
{ {
return view('home'); return view('home');
} }
public function changeLocale(Request $request)
{
$language = $request->language ?? 'en';
session(['selected_language' => $language]);
return redirect()->back();
}
} }
...@@ -35,6 +35,7 @@ class Kernel extends HttpKernel ...@@ -35,6 +35,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\Localization::class, //add your localization middleware here
], ],
'api' => [ 'api' => [
......
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\App;
class Localization
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
App::setLocale(session()->get('selected_language') ?? 'en');
return $next($request);
}
}
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
<!-- PAGE CONTENT --> <!-- PAGE CONTENT -->
<div class="page-content"> <div class="page-content">
<!-- START X-NAVIGATION VERTICAL --> <!-- START X-NAVIGATION VERTICAL -->
<ul class="x-navigation x-navigation-horizontal x-navigation-panel"> <ul class="x-navigation x-navigation-horizontal x-navigation-panel">
<!-- TOGGLE NAVIGATION --> <!-- TOGGLE NAVIGATION -->
...@@ -66,6 +65,14 @@ ...@@ -66,6 +65,14 @@
<li class="xn-icon-button pull-right"> <li class="xn-icon-button pull-right">
<a href="#" class="mb-control" data-box="#mb-signout"><span class="fa fa-sign-out"></span></a> <a href="#" class="mb-control" data-box="#mb-signout"><span class="fa fa-sign-out"></span></a>
</li> </li>
<li class="pull-right">
<div style = "padding-top: 15px;">
{!! Form::open(array('url' => route('language'), 'method' => 'POST', 'id' => 'pages', 'files' => true)) !!}
{!! Form::select('language', ['id'=>'Indonesia', 'en'=>'English'], Session::get('selected_language'), ['onChange'=>'this.form.submit();']) !!}
<button type="submit" style="display: none;">simpan</button>
{!! Form::close() !!}
</div>
</li>
<!-- END SIGN OUT --> <!-- END SIGN OUT -->
</ul> </ul>
<!-- END X-NAVIGATION VERTICAL --> <!-- END X-NAVIGATION VERTICAL -->
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
@section('breadcrumbs') @section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> <li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.post')</li> <li class="active">@lang('feature.page')</li>
@stop @stop
@section('content') @section('content')
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<th width="5%" style="text-align: center;">@lang('label.number')</th> <th width="5%" style="text-align: center;">@lang('label.number')</th>
<th style="text-align: center;">@lang('label.title')</th> <th style="text-align: center;">@lang('label.title')</th>
<th width="20%" style="text-align: center;">@lang('label.sum')</th> <th width="20%" style="text-align: center;">@lang('label.sum')</th>
<th align="center" width="10%" style="text-align: center;">@lang('label.action')</th> <th align="center" width="15%" style="text-align: center;">@lang('label.action')</th>
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
......
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
<table class="table table-hover data-table" width="100%"> <table class="table table-hover data-table" width="100%">
<thead> <thead>
<tr> <tr>
<th width="7%" style="text-align: center;">@lang('label.number')</th> <th width="5%" style="text-align: center;">@lang('label.number')</th>
<th width="38%" style="text-align: center;">@lang('label.title')</th> <th width="38%" style="text-align: center;">@lang('label.title')</th>
<th width="15%" style="text-align: center;">@lang('label.category')</th> <th width="15%" style="text-align: center;">@lang('label.category')</th>
<th width="15%" style="text-align: center;">@lang('label.date')</th> <th width="10%" style="text-align: center;">@lang('label.date')</th>
<th width="15%" style="text-align: center;">@lang('label.sum')</th> <th width="15%" style="text-align: center;">@lang('label.sum')</th>
<th align="center" width="10%" style="text-align: center;">@lang('label.action')</th> <th align="center" width="15%" style="text-align: center;">@lang('label.action')</th>
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
......
...@@ -17,4 +17,5 @@ Route::get('/', function () { ...@@ -17,4 +17,5 @@ Route::get('/', function () {
Auth::routes(); Auth::routes();
Route::post('/change-language', 'HomeController@changeLocale')->name('language');
Route::get('/home', 'HomeController@index')->name('home'); Route::get('/home', 'HomeController@index')->name('home');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment