Commit d56c9620 by Aan Choesni Herlingga

first step change language

parent f24cb7f1
......@@ -25,4 +25,12 @@ class HomeController extends Controller
{
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
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\Localization::class, //add your localization middleware here
],
'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 @@
<!-- PAGE CONTENT -->
<div class="page-content">
<!-- START X-NAVIGATION VERTICAL -->
<ul class="x-navigation x-navigation-horizontal x-navigation-panel">
<!-- TOGGLE NAVIGATION -->
......@@ -66,6 +65,14 @@
<li class="xn-icon-button pull-right">
<a href="#" class="mb-control" data-box="#mb-signout"><span class="fa fa-sign-out"></span></a>
</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 -->
</ul>
<!-- END X-NAVIGATION VERTICAL -->
......
......@@ -11,7 +11,7 @@
@section('breadcrumbs')
<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
@section('content')
......@@ -34,7 +34,7 @@
<th width="5%" style="text-align: center;">@lang('label.number')</th>
<th style="text-align: center;">@lang('label.title')</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>
</thead>
<tbody></tbody>
......
......@@ -31,12 +31,12 @@
<table class="table table-hover data-table" width="100%">
<thead>
<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="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 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>
</thead>
<tbody></tbody>
......
......@@ -17,4 +17,5 @@ Route::get('/', function () {
Auth::routes();
Route::post('/change-language', 'HomeController@changeLocale')->name('language');
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