mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
Starting to add localization into PTB
This commit is contained in:
parent
b49ec06062
commit
9a66b65f38
@ -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\Locale::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
|
21
app/Http/Middleware/Locale.php
Normal file
21
app/Http/Middleware/Locale.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class Locale
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
\App::setLocale(session('lang'));
|
||||
return $next($request);
|
||||
}
|
||||
}
|
12
resources/lang/en/home.php
Normal file
12
resources/lang/en/home.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// /resources/views/home.blade.php
|
||||
|
||||
return [
|
||||
'no_messages' => 'There are no items shared with you yet.',
|
||||
'share_item' => 'Share an item!',
|
||||
'return' => 'Return It',
|
||||
'cancel_alert' => 'Cancel Alert',
|
||||
'alert_me' => 'Alert me',
|
||||
'take' => 'Take It'
|
||||
];
|
12
resources/lang/pt-br/home.php
Normal file
12
resources/lang/pt-br/home.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// /resources/views/home.blade.php
|
||||
|
||||
return [
|
||||
'no_messages' => 'Ainda não há itens compartilhados com você.',
|
||||
'share_item' => 'Compartilhe um item!',
|
||||
'return' => 'Retornar',
|
||||
'cancel_alert' => 'Cancelar alerta',
|
||||
'alert_me' => 'Alertar',
|
||||
'take' => 'Pegar'
|
||||
];
|
@ -33,7 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p>There are no items shared with you yet. <a href="/product">Share an item!</a></p>
|
||||
<p>@lang('home.no_messages')<a href="/product">@lang('home.share_item')</a></p>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<form action="/take" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-sm btn-success">Take It</button>
|
||||
<button type="submit" class="btn btn-sm btn-success">@lang('home.take')</button>
|
||||
</form>
|
@ -5,7 +5,7 @@
|
||||
{{ csrf_field() }}
|
||||
@method('DELETE')
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-sm btn-danger ml-auto">Return It</button>
|
||||
<button type="submit" class="btn btn-sm btn-danger ml-auto">@lang('home.return')</button>
|
||||
</form>
|
||||
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
@if ($item->waiting_user_id == \Auth::id())
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger ml-auto">Cancel Alert</button>
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger ml-auto">@lang('home.cancel_alert')</button>
|
||||
@elseif (!$item->waiting_user_id)
|
||||
<button type="submit" class="btn btn-sm btn-outline-secondary ml-auto">Alert me</button>
|
||||
<button type="submit" class="btn btn-sm btn-outline-secondary ml-auto">@lang('home.alert_me')</button>
|
||||
@endif
|
||||
</form>
|
||||
@endif
|
@ -15,6 +15,12 @@ Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Route::get('/lang/{locale}', function ($locale) {
|
||||
session(['lang' => $locale]);
|
||||
session()->save();
|
||||
return back();
|
||||
});
|
||||
|
||||
Route::get('/product', 'ProductController@index')->middleware('verified');
|
||||
Route::get('/product/{product}', 'ProductController@show')->middleware('verified');
|
||||
Route::post('/product', 'ProductController@store')->middleware('verified');
|
||||
|
Loading…
Reference in New Issue
Block a user