From 9a66b65f38cd80caf66ee621d4ba2fdf11ff67e9 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 26 Sep 2018 22:52:43 -0300 Subject: [PATCH] Starting to add localization into PTB --- app/Http/Kernel.php | 1 + app/Http/Middleware/Locale.php | 21 +++++++++++++++++++++ resources/lang/en/home.php | 12 ++++++++++++ resources/lang/pt-br/home.php | 12 ++++++++++++ resources/views/home.blade.php | 2 +- resources/views/home/unusedItem.blade.php | 2 +- resources/views/home/usedItem.blade.php | 6 +++--- routes/web.php | 6 ++++++ 8 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 app/Http/Middleware/Locale.php create mode 100644 resources/lang/en/home.php create mode 100644 resources/lang/pt-br/home.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 0e5dff8..1dbc060 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -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' => [ diff --git a/app/Http/Middleware/Locale.php b/app/Http/Middleware/Locale.php new file mode 100644 index 0000000..b60c229 --- /dev/null +++ b/app/Http/Middleware/Locale.php @@ -0,0 +1,21 @@ + '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' +]; \ No newline at end of file diff --git a/resources/lang/pt-br/home.php b/resources/lang/pt-br/home.php new file mode 100644 index 0000000..0c0c3cf --- /dev/null +++ b/resources/lang/pt-br/home.php @@ -0,0 +1,12 @@ + 'Ainda não há itens compartilhados com você.', + 'share_item' => 'Compartilhe um item!', + 'return' => 'Retornar', + 'cancel_alert' => 'Cancelar alerta', + 'alert_me' => 'Alertar', + 'take' => 'Pegar' +]; \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 6bfd47d..4d419e0 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -33,7 +33,7 @@ @empty -

There are no items shared with you yet. Share an item!

+

@lang('home.no_messages')@lang('home.share_item')

@endforelse diff --git a/resources/views/home/unusedItem.blade.php b/resources/views/home/unusedItem.blade.php index 3aefc6e..8d91be4 100644 --- a/resources/views/home/unusedItem.blade.php +++ b/resources/views/home/unusedItem.blade.php @@ -1,5 +1,5 @@
{{ csrf_field() }} - +
\ No newline at end of file diff --git a/resources/views/home/usedItem.blade.php b/resources/views/home/usedItem.blade.php index dcfe35f..d4f7c9e 100644 --- a/resources/views/home/usedItem.blade.php +++ b/resources/views/home/usedItem.blade.php @@ -5,7 +5,7 @@ {{ csrf_field() }} @method('DELETE') - + @@ -23,9 +23,9 @@ @if ($item->waiting_user_id == \Auth::id()) @method('DELETE') - + @elseif (!$item->waiting_user_id) - + @endif @endif \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 5df9f98..7c582d2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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');